.cr-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.cr-toolbar .layui-btn { margin: 0; }
.cr-toolbar-right { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.cr-switch-wrap { display: inline-flex; align-items: center; }
.cr-switch-wrap .layui-form-switch { margin: 0; }

/* 主体布局 */
.cr-body {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    height: calc(100vh - 200px);
    min-height: 480px;
}
.cr-pane {
    display: flex;
    flex-direction: column;
    flex: 1 1 50%;
    min-width: 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
    overflow: hidden;
}
.cr-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    height: 42px;
    padding: 0 10px 0 0;
    background: #f7f8fa;
    border-bottom: 1px solid #eef0f4;
}
.cr-title { padding-left: 12px; font-size: 13px; color: #5f6b7a; }
.cr-title .layui-icon { margin-right: 4px; color: #16baaa; }

/* 语言切换标签 */
.cr-tabs { display: flex; height: 100%; }
.cr-tab {
    position: relative;
    height: 100%;
    padding: 0 18px;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: #5f6b7a;
    cursor: pointer;
    transition: all .2s;
}
.cr-tab:hover { color: #16baaa; }
.cr-tab.active { color: #16baaa; background: #fff; }
.cr-tab.active::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: #16baaa;
}
.cr-tab::after {
    content: '';
    position: absolute;
    right: 0; top: 12px; bottom: 12px;
    width: 1px;
    background: #eef0f4;
}
.cr-tab:last-child::after { display: none; }

/* 编辑器 */
.cr-editors { position: relative; flex: 1 1 auto; min-height: 0; }
.cr-editor-item { position: absolute; inset: 0; display: none; }
.cr-editor-item.active { display: flex; }
.cr-gutter {
    flex: 0 0 48px;
    width: 48px;
    padding: 10px 8px 10px 0;
    overflow: hidden;
    text-align: right;
    color: #a6b1bf;
    background: #f7f8fa;
    font: 13px/20px Consolas, Monaco, "Courier New", monospace;
    user-select: none;
}
.cr-textarea {
    flex: 1 1 auto;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    outline: none;
    resize: none;
    overflow: auto;
    white-space: pre;
    tab-size: 2;
    -moz-tab-size: 2;
    color: #243b53;
    background: #fff;
    font: 13px/20px Consolas, Monaco, "Courier New", monospace;
}
.cr-textarea::placeholder { color: #b8c1cc; }

/* 预览区 */
.cr-preview-body { position: relative; flex: 1 1 auto; min-height: 0; background: #fff; }
.cr-preview-body iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.cr-mini-btn {
    padding: 0 8px;
    border: 0;
    background: transparent;
    color: #8b98a9;
    font-size: 15px;
    cursor: pointer;
    transition: color .2s;
}
.cr-mini-btn:hover { color: #16baaa; }

/* 控制台 */
.cr-console {
    display: flex;
    flex-direction: column;
    flex: 0 0 150px;
    border-top: 1px solid #eef0f4;
    background: #1e2430;
    max-height: 50vh;
}
.cr-console-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    color: #8b98a9;
    background: #171c26;
}
.cr-console-clear { cursor: pointer; transition: color .2s; }
.cr-console-clear:hover { color: #16baaa; }
.cr-console-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 6px 10px;
    color: #cbd5e1;
    font: 12px/1.7 Consolas, Monaco, "Courier New", monospace;
}
.cr-console-line {
    padding: 2px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, .06);
    white-space: pre-wrap;
    word-break: break-all;
}
.cr-console-line.warn { color: #f7b84b; }
.cr-console-line.error { color: #ff7875; }
.cr-console-line.system { color: #6b7a90; }

/* 滚动条 */
.cr-console-body::-webkit-scrollbar,
.cr-textarea::-webkit-scrollbar { width: 8px; height: 8px; }
.cr-console-body::-webkit-scrollbar-thumb { background: #39404f; border-radius: 4px; }
.cr-textarea::-webkit-scrollbar-thumb { background: #d8dee7; border-radius: 4px; }
.cr-textarea::-webkit-scrollbar-track { background: #f7f8fa; }

/* 响应式 */
@media screen and (max-width: 992px) {
    /* 上下堆叠，不再固定 440px */
    .cr-body {
        flex-direction: column;
        height: auto;
        gap: 12px;
    }

    /* 左侧编辑区：写代码的地方，给足高度 */
    .cr-left {
        height: 70vh;   /* 老浏览器兜底 */
        height: 70dvh;  /* 支持动态视口，键盘弹出时自动收缩，不会顶飞 */
        min-height: 420px;
    }

    /* 右侧预览区：预览 + 控制台 */
    /*.cr-right {
        height: 85vh;
        height: 85dvh;
        min-height: 480px;
    }
*/
    /* 移动端把控制台压矮一点，把空间让给预览 */
    .cr-console {
        flex: 0 0 110px;
    }

    /* 字号行高放大，手指点选更准，阅读也舒服 */
    .cr-textarea,
    .cr-gutter {
        font-size: 15px;
        line-height: 22px;
    }
    .cr-textarea { padding: 10px; }
    .cr-gutter {
        flex: 0 0 40px;
        width: 40px;
        padding: 10px 6px 10px 0;
    }

    /* 工具栏换行 */
    .cr-toolbar-right {
        margin-left: 0;
        width: 100%;
    }
}
/* 工具说明 */
.cr-help {
    margin-top: 4px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
    overflow: hidden;
}
.cr-help-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #243b53;
    border-bottom: 1px solid #eef0f4;
}
.cr-help-head .layui-icon { color: #16baaa; font-size: 16px; }
.cr-help .layui-colla-title {
    height: 42px;
    line-height: 42px;
    padding-left: 42px;
    font-size: 13px;
    color: #5f6b7a;
    background: #fafbfc;
}
.cr-help .layui-colla-content {
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.9;
    color: #5f6b7a;
}
.cr-help-list { margin: 0; padding-left: 18px; }
.cr-help-list li { margin-bottom: 6px; }
.cr-help-list li:last-child { margin-bottom: 0; }
.cr-help kbd {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    border: 1px solid #dfe4ec;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #f7f8fa;
    color: #243b53;
    font: 12px/1.6 Consolas, Monaco, monospace;
    text-align: center;
}
.cr-help .cr-tag {
    display: inline-block;
    padding: 0 6px;
    border-radius: 3px;
    background: #e8f8f6;
    color: #0f9e90;
    font-size: 12px;
}
