html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}

/* 关卡页底色与横幅背景一致（#6B2737），顶栏/任务条同色 */
.level-page {
    background: #6B2737;
}

.level-page .lab-toolbar {
    background: #6B2737;
}

/* Blockly 工具箱分类列表：手机端缩小字号、空隙与行高，电脑端保持原大小 */
.blocklyToolboxCategoryLabel {
    font-size: 13px !important;
    padding-left: 2px !important;
}

.blocklyToolboxCategoryIcon {
    width: 5px !important;
}

.blocklyToolboxCategory {
    height: 18px !important;
    line-height: 18px !important;
}

.blocklyToolboxCategory .blocklyTreeRowContentContainer {
    line-height: 18px !important;
}

@media (min-width: 768px) {
    .blocklyToolboxCategory {
        display: flex;
        align-items: center;
    }
    .blocklyToolboxCategory .blocklyTreeRowContentContainer {
        display: flex;
        align-items: center;
    }
    .blocklyToolboxCategoryLabel {
        font-size: 16px !important;
        padding-left: 3px !important;
        line-height: 1 !important;
    }
    .blocklyFlyout .blocklyText,
    .blocklyFlyout .blocklyDropdownText,
    .blocklyFlyout .blocklyVariableDropdownText {
        dominant-baseline: auto;
    }

    .blocklyToolboxCategoryIcon {
        width: 16px !important;
    }

    .blocklyToolboxCategory {
        height: 22px !important;
        line-height: 22px !important;
    }

    .blocklyToolboxCategory .blocklyTreeRowContentContainer {
        line-height: 22px !important;
    }
}

.lab-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 8px;
    padding-top: env(safe-area-inset-top);
    background: #2c3e50;
    color: #fff;
    flex: none;
    z-index: 30;
}

.lab-title {
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40%;
}

.lab-btn {
    display: inline-block;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: #fff;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    text-decoration: none;
    line-height: 1.2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.lab-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.lab-btn--primary {
    background: #3498db;
    border-color: #3498db;
}

.lab-btn-group {
    display: flex;
    gap: 8px;
}

/* 关卡页导航栏：选关、关卡及编号、得分、图标按钮（参照航空运输顶栏布局） */
.lab-toolbar--level {
    justify-content: flex-start;
    gap: 6px;
    padding-left: 6px;
    padding-right: 6px;
}

.lab-btn--back {
    padding: 6px 8px;
    font-size: 13px;
    white-space: nowrap;
    flex: none;
    border: none;
    background: transparent;
}

.lab-title--level {
    flex: 1;
    max-width: none;
    min-width: 0;
    font-size: 14px;
}

/* 关卡页标题可点击重开任务弹窗 */
.lab-title--open {
    cursor: pointer;
}

/* 得分胶囊（参照极速配送 .m-hud-score） */
.lab-score {
    font-size: 13px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 10px;
    color: #fff;
    white-space: nowrap;
    flex: none;
}

.lab-btn-group--icons {
    gap: 4px;
    flex: none;
}

/* 图标按钮（参照极速配送 .m-hud-btn：半透明白底圆角） */
.lab-btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.lab-btn--icon:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.94);
}

.lab-btn--icon svg {
    display: block;
}

/* 运行按钮（参照极速配送 .m-hud-run：黄色填充） */
.lab-btn--run {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #ffd23b;
    color: #000;
}

.lab-btn--run:active {
    background: #eab502;
    transform: scale(0.94);
}

.lab-btn--run svg {
    display: block;
}

/* 运行中：省略号呼吸动画 */
.lab-btn--loading {
    font-size: 18px;
    font-weight: bold;
    animation: lab-pulse 1s ease-in-out infinite;
}

@keyframes lab-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.lab-workspace {
    flex: 1;
    width: 100%;
    min-height: 0;
}

/* 运行结果面板：显示在 Blockly 编程区上方（参照航空运输移动端布局）。
   图像显示区为固定 4:3 取景框（280x210），图像等比适配框内。 */
.result-panel {
    flex: none;
    height: 300px;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-bottom: 1px solid #333;
}

.result-images {
    flex: none;
    position: relative;
    width: 280px;
    height: 210px;
    margin: 6px auto 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    z-index: 1; /* 学生结果图覆盖在幽灵参考图上方 */
}

.result-images:empty {
    display: none;
}

/* 「看图写程序」幽灵参考图：绝对定位覆盖结果图区域（result-stage），
   仅在全图模式与未运行时显示（JS 控制），结果图在其上方，图 20% 不透明度（对齐海龟绘图） */
.result-stage {
    /* 占满面板剩余空间并作为 flex 容器：单图 fit 的 margin:auto 在其中垂直居中，
       与引入参考图之前的居中行为一致；幽灵层绝对定位覆盖整个 stage */
    flex: 1 1 auto;
    display: flex;
    position: relative;
    width: 100%;
    min-height: 210px;
    margin: 6px 0 0;
}
.result-stage .result-images {
    margin: 0 auto;
}
.ghost-answer {
    /* 预览参考图与全图模式结果图共用同一套几何约束（宽度均分 + 高度上限），
       未运行时看到的参考图与运行后全图的结果图同尺寸同位置——逐像素对齐 */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: calc(100% - 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 0;
    pointer-events: none;           /* 不拦截结果图的点击/缩放 */
}
.ghost-answer[hidden] { display: none; }
.ghost-answer--off { display: none; }
.ghost-answer__img {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    max-height: 240px;              /* 与 .result-images.full-fit .result-image 一致 */
    max-width: calc((100% - (var(--n, 1) - 1) * 8px) / var(--n, 1));
    object-fit: contain;
    /* 与海龟绘图项目一致：答案图以 0.2 不透明度铺在画布底层 */
    opacity: 0.2;
}
/* 全图模式的结果格子：对应序号的参考图垫在格子底层，
   与学生结果图同一盒子 + 同样的 object-fit:contain —— 尺寸正确时逐像素对齐 */
.result-cell {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.result-cell img.result-image {
    position: relative;
    z-index: 1;
    /* 全图模式格子的宽度限制（JS 设置 maxWidth）不能让图片溢出格子造成重叠 */
    max-width: 100%;
}
.result-cell img.ghost-result {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0.2;
    pointer-events: none;
    z-index: 2; /* 叠在结果图上层（洋葱皮对比）：正确结果也始终能看到参考图 */
}

/* 「参考图」显隐开关（眼睛图标）：标签栏行尾右对齐 */
.ghost-toggle {
    margin-left: auto;
    align-self: center;
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ghost-toggle--off { opacity: 0.45; }

.result-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #333;
    flex: none;
}

/* 2~3 张图并排对比显示：flex 平分扣除 gap 后的空间（不用固定百分比，
   否则 flex:none + gap 会溢出触发横向滚动条）；超过 3 张保留横向滑动 */
.result-images.count-2 .result-image,
.result-images.count-3 .result-image {
    flex: 1 1 0;
    min-width: 0;
}

.result-images.count-many .result-image {
    width: 72%;
}

.result-image {
    cursor: zoom-in;
}

/* 视频管线：处理后的视频播放器 */
.result-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    flex: none;
}
/* 视频与单张图像一致：fit 容器内按视频真实分辨率居中显示（超限才缩小） */
.result-images.fit .result-video {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 240px;
}

/* 多视频：纵向排列、垂直居中、无滚动条；变量名做成左下角小角标 */
.result-images.video-list {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
.result-cell.video-cell {
    position: relative;
    flex: 0 1 50%;
    min-height: 0;
    margin: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.video-label {
    position: absolute;
    left: 6px;
    bottom: 6px;
    font-size: 11px;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 4px;
    padding: 1px 6px;
    pointer-events: none;
}
.video-cell .result-video {
    width: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* 多图滑动提示（已移除：不再在图片上覆盖文字注释） */

/* 单图模式：窗口跟随图像真实分辨率（自然尺寸显示，超限才缩小）。
   手机端宽度随屏、高度上限取面板预算（300px 面板 − 标签页 − 控制条 ≈ 240px）；
   桌面端上限在下方 768px 媒体查询里按视口放宽。 */
.result-images.fit {
    display: block;
    width: fit-content;
    max-width: calc(100% - 12px);
    height: fit-content;
    margin: auto;
    background: transparent;
    border: none;
    overflow: hidden;
}

.result-images.fit .result-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 240px;
    /* contain：盒子与内容尺寸不匹配时也不裁剪（none 会露出图像中心带，
       竖图在高度受限的面板里表现为“头顶被切掉”） */
    object-fit: contain;
}

/* 全图模式：容器占满图像区宽，每张图的 max-width 由 JS 均分（calc 百分比），
   图片通过内在尺寸约束真实等比缩放——不能靠 flex-shrink 收缩（只裁盒子不缩位图） */
.result-images.full-fit {
    width: 100%;
    max-width: calc(100% - 12px);
    height: auto;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
    background: transparent;
    border: none;
}

.result-images.full-fit .result-image {
    width: auto;
    height: auto;
    /* 尺寸由 JS 统一比例布局（方格 S×S，最大边 M 的图像缩放 S/M）计算 */
    max-height: none;
    flex: 0 0 auto;
    object-fit: contain;
}

/* 滚轮缩放：单张翻页态也裁剪，缩放中心由 JS 按指针位置设置 */
.result-images.count-1 { overflow: hidden; }
.result-images .result-image { transform-origin: 50% 50%; }

/* 图像控制条：单张/全图 + 前后翻页 */
.image-controls {
    flex: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 4px 0 2px;
}

.image-controls[hidden] {
    display: none;
}

.img-ctrl {
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 5px;
    color: #ccc;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.img-ctrl:disabled {
    opacity: 0.35;
    cursor: default;
}

/* 全屏图片查看器：点击放大单张，可左右滑动/箭头切换 */
.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.image-viewer.open {
    display: flex;
}

.viewer-img {
    max-width: 92vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 4px;
    background: #222;
}

.viewer-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}

.viewer-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.viewer-close {
    top: calc(10px + env(safe-area-inset-top));
    right: 12px;
    font-size: 20px;
}

.viewer-prev {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.viewer-next {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.viewer-save {
    bottom: calc(56px + env(safe-area-inset-bottom));
    right: 12px;
    font-size: 20px;
}

.viewer-count {
    position: absolute;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    color: #ddd;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 12px;
    border-radius: 12px;
}

.result-text {
    flex: 1;
    margin: 0;
    padding: 4px 12px 6px;
    overflow: auto;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 弹窗样式（参照极速配送）：半透明遮罩 + 白色圆角卡片 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.open {
    display: flex;
}

.result-modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
}

/* 得分弹窗：尺寸/内边距与任务说明弹窗对齐（520/680px），右上角关闭按钮 */
.score-modal-card {
    position: relative;
    box-sizing: border-box;
    max-width: 520px;
    padding: 26px 22px;
}

.score-modal__close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    background: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
}

/* 得分弹窗内部文字/金币按新尺寸放大（限定作用域，不影响代码弹窗共用样式） */
.score-modal-card .result-title {
    font-size: 28px;
    margin-bottom: 14px;
}

.score-modal-card .result-num {
    font-size: 24px;
    margin: 8px 0;
}

.score-modal-card .result-detail {
    font-size: 15px;
}

.score-modal-card .result-detail-row {
    gap: 8px;
    margin-bottom: 6px;
}

.score-modal-card .result-coin {
    width: 24px;
    height: 24px;
    margin-right: 3px;
}

.score-modal-card .result-btn {
    font-size: 16px;
    padding: 10px 32px;
}

/* 任务说明弹窗：比得分弹窗更宽，正文左对齐，顶部标题/关闭 + 底部「开始闯关」
   （放在 .result-modal 之后，靠源顺序覆盖其 max-width/居中） */
.task-modal {
    box-sizing: border-box;
    text-align: left;
    max-width: 520px;
    padding: 26px 22px;
}

.task-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.task-modal__title {
    font-size: 19px;
    font-weight: bold;
    color: #222;
}

.task-modal__close {
    border: none;
    background: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
}

.task-modal__body {
    font-size: 16px;
    line-height: 1.7;
    color: #333;
    max-height: 55vh;
    overflow-y: auto;
}

/* 任务说明 md 渲染元素 */
.task-modal__body p {
    margin: 0 0 10px;
}

.task-modal__body p:last-child {
    margin-bottom: 0;
}

.task-modal__body h1,
.task-modal__body h2,
.task-modal__body h3,
.task-modal__body h4 {
    margin: 14px 0 6px;
    color: #222;
    line-height: 1.4;
}

.task-modal__body h1 { font-size: 20px; }
.task-modal__body h2 { font-size: 18px; }
.task-modal__body h3 { font-size: 17px; }
.task-modal__body h4 { font-size: 16px; }

.task-modal__body ul,
.task-modal__body ol {
    margin: 0 0 10px;
    padding-left: 22px;
}

.task-modal__body li {
    margin-bottom: 4px;
}

.task-modal__body code {
    background: #f2f4f6;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}

.task-modal__body pre {
    background: #f6f8fa;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 0 0 10px;
    overflow-x: auto;
}

.task-modal__body pre code {
    background: none;
    padding: 0;
}

.task-modal__body img {
    max-width: 70%;
    display: block;
    margin: 10px 0;
    border-radius: 6px;
    border: 1px solid #e3e6ea;
}

/* 桌面端任务/得分弹窗统一更宽，任务配图比例相应收紧 */
@media (min-width: 768px) {
    .task-modal,
    .score-modal-card {
        max-width: 680px;
        padding: 32px 28px;
    }

    .task-modal__body img {
        max-width: 60%;
    }
}

.result-title {
    font-size: 24px;
    margin-bottom: 12px;
    color: #c62828;
}

.result-title.win {
    color: #2e7d32;
}

.result-num {
    font-size: 20px;
    font-weight: bold;
    margin: 6px 0;
    color: #333;
}

.result-detail {
    font-size: 13px;
    color: #666;
    margin: 8px auto 0;
}

.result-detail-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

.result-detail-label {
    font-weight: 600;
    color: #555;
    flex: 0 0 auto;
}

.result-detail-score {
    margin-left: auto;
    flex: 0 0 auto;
    color: #666;
}

/* 金币（参照极速配送 .result-coins/.result-coin） */
.result-coins {
    display: inline-flex;
    align-items: center;
}

.result-coin {
    width: 18px;
    height: 18px;
    margin-right: 2px;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

.result-btn {
    border: 2px solid #90a4ae;
    background: #fff;
    border-radius: 24px;
    padding: 8px 26px;
    font-size: 15px;
    cursor: pointer;
    color: #455a64;
}

.result-btn.primary {
    background: #f89938;
    border-color: #e65100;
    color: #fff;
}

/* 代码弹窗卡片 */
.code-card {
    padding: 0;
    overflow: hidden;
    text-align: left;
    position: relative;
}

.code-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-size: 15px;
    font-weight: bold;
    color: #333;
    flex: none;
}

/* 代码弹窗放大一倍（相对结果弹窗 420px 宽）且固定高度：窗口 80vh，代码区内部滚动 */
.code-card {
    max-width: 840px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.code-sheet__actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.code-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    font-size: 13px;
}

.code-close svg {
    display: block;
}

.code-sheet__content {
    margin: 0;
    padding: 12px 16px;
    flex: 1;
    min-height: 0;
    overflow: auto;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    background: #f6f6f6;
    color: #333;
}

/* 复制成功提示：卡片中央短暂浮现 1 秒 */
.code-copy-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
    z-index: 10;
}

.code-copy-toast.show {
    opacity: 1;
    visibility: visible;
}



/* ===== 桌面布局：编程区在左、结果显示在右（参照航空运输） ===== */
#workspace-row {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

@media (min-width: 768px) {
    #workspace-row {
        flex-direction: row;
    }
    #workspace-row .lab-workspace {
        order: -1;
        flex: 1;
        width: auto;
    }
    #workspace-row .result-panel {
        flex: 1;
        height: auto;
        border-bottom: none;
        border-left: 1px solid #333;
        max-width: 50%;
    }
    /* 桌面端显示窗口按电脑屏幕适配：高度预算扣掉工具栏(48) + 关卡任务(最高25vh)
       + 标签页(36) + 控制条(34)，竖图完整缩进可视区；容器溢出时兜底滚动 */
    .result-images.fit .result-image,
    .result-images.fit .result-video,
    .ghost-answer__img {
        max-height: calc(100vh - 430px);
    }
    .result-images.fit,
    .result-images.full-fit {
        max-height: calc(100vh - 118px);
        overflow-y: auto;
    }
    /* flyout 收紧：文字更小、字段更窄，展开后给编程区留出空间 */
    .blocklyFlyout .blocklyText,
    .blocklyFlyout .blocklyDropdownText {
        font-size: 14px !important;
    }
    .blocklyFlyout .blocklyHtmlInput {
        font-size: 14px !important;
        width: 80px !important;
        padding: 0 2px !important;
    }
    .blocklyFlyout .blocklyDropdownText,
    .blocklyFlyout .blocklyVariableDropdownText {
        max-width: 64px !important;
        overflow: hidden !important;
    }
    .blocklyFlyout .blocklyDropdownText.blocklyDropdownTextFilled,
    .blocklyFlyout .blocklyVariableDropdownText {
        width: auto !important;
    }
}


/* 结果面板标签页：图像 / 输出 */
.result-tabs {
    flex: none;
    display: flex;
    gap: 6px;
    padding: 4px 8px 0;
    position: relative; /* 「看图写程序」幽灵参考图的定位锚点 */
}
.result-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 6px 6px 0 0;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}

.result-tab svg {
    display: block;
}
.result-tab.active {
    background: #2a2a2a;
    color: #fff;
    border-bottom-color: #2a2a2a;
}

/* 输出区：程序输出 + 出错信息分段 */
.result-output {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 聊天室气泡视图（第 105/106 关 [AI] 角色名：内容 标记触发） */
.chat-room {
    flex: none;
    max-height: 45%;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px dashed #d8dee6;
}
.chat-msg {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    max-width: 86%;
    align-self: flex-start;
}
.chat-msg:nth-child(even) {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-msg__name {
    font-size: 12px;
    font-weight: bold;
    padding: 0 4px;
}
.chat-msg__bubble {
    padding: 8px 12px;
    border-radius: 12px;
    background: #eef2f7;
    color: #333;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg:nth-child(even) .chat-msg__bubble {
    background: #e0e7ff;
}
.result-error {
    flex: none;
    margin: 0 8px 6px;
    padding: 6px 8px;
    background: rgba(198, 40, 40, 0.18);
    border: 1px solid #c62828;
    border-radius: 6px;
    color: #ff8a80;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    overflow: auto;
    max-height: 40%;
}

/* 交互式运行控制台 */
.run-console {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
}
.run-console__stream {
    flex: 1;
    min-height: 0;
    margin: 0;
    overflow-y: auto;
    padding: 8px 10px;
    background: #1e1e2e;
    color: #d4d4d4;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 8px;
}
.run-console__inputrow {
    flex: none;
    display: flex;
    gap: 8px;
}
.run-console__input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
}
.run-console__send {
    flex: none;
    padding: 8px 16px;
}
