/* 在线运行 JS：上编辑 / 中按钮 / 下输出，风格贴近首页浅色工作区 */

.tool-form-js-runner .orj-workspace {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 640px;
    padding: 12px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
}

.tool-form-js-runner .orj-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid #ececec;
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
}

.tool-form-js-runner .orj-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #ececec;
}

.tool-form-js-runner .orj-panel-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.tool-form-js-runner .orj-panel-meta {
    font-size: 12px;
    color: #888;
}

.tool-form-js-runner .orj-editor-host {
    height: 320px;
    background: #fff;
}

.tool-form-js-runner #orj-editor,
.tool-form-js-runner .orj-editor-host .ace_editor {
    width: 100%;
    height: 100%;
}

/* 与 JavaScript 格式化页一致的编辑器字号 / 行高 */
.tool-form-js-runner #orj-editor.ace_editor,
.tool-form-js-runner .orj-editor-host .ace_editor {
    font-size: 14.8px !important;
    line-height: 20px !important;
}

.tool-form-js-runner #orj-editor .ace_gutter-cell,
.tool-form-js-runner .orj-editor-host .ace_gutter-cell {
    color: #6e6e6e;
    font-size: 0.925rem;
}

/* 语法着色略压暗，减轻刺眼感（仅本页） */
.tool-form-js-runner .ace-monaco-vs-javascript {
    color: #222 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_line {
    color: #222 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_identifier {
    color: #222 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_keyword,
.tool-form-js-runner .ace-monaco-vs-javascript .ace_storage.ace_type,
.tool-form-js-runner .ace-monaco-vs-javascript .ace_constant.ace_language,
.tool-form-js-runner .ace-monaco-vs-javascript .ace_support.ace_function {
    color: #0000b8 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_string {
    color: #8b1010 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_comment {
    color: #006000 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_constant.ace_numeric {
    color: #066648 !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_keyword.ace_operator,
.tool-form-js-runner .ace-monaco-vs-javascript .ace_paren {
    color: #1a1a1a !important;
}

/* 文本选中高亮 */
.tool-form-js-runner .ace-monaco-vs-javascript .ace_marker-layer .ace_selection {
    background: #add6ff !important;
}
.tool-form-js-runner .ace-monaco-vs-javascript .ace_marker-layer .ace_selected-word {
    border: 1px solid #add6ff !important;
    background: rgba(173, 214, 255, 0.35) !important;
}


.tool-form-js-runner .orj-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 2px 2px 0;
}

.tool-form-js-runner .orj-actions .btn {
    min-width: 0;
    margin-right: 0;
    padding: .35rem .55rem;
}


.tool-form-js-runner .orj-history-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tool-form-js-runner .orj-history-btn-text {
    line-height: 1;
}

.tool-form-js-runner .orj-history-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 999px;
    background: #52c41a;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    box-sizing: border-box;
    pointer-events: none;
}

.tool-form-js-runner .orj-history-badge[hidden] {
    display: none !important;
}

.tool-form-js-runner .orj-actions .btn.is-active {
    background: #1677ff;
    border-color: #1677ff;
    color: #fff;
}

.tool-form-js-runner .orj-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 12px;
    color: #666;
}

.tool-form-js-runner .orj-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bfbfbf;
}

.tool-form-js-runner .orj-status-dot.is-running {
    background: #faad14;
    animation: orj-pulse 0.8s ease-in-out infinite;
}

.tool-form-js-runner .orj-status-dot.is-done {
    background: #52c41a;
}

.tool-form-js-runner .orj-status-dot.is-error {
    background: #ff4d4f;
}

.tool-form-js-runner .orj-status-dot.is-idle {
    background: #bfbfbf;
}

@keyframes orj-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.tool-form-js-runner .orj-tabs {
    display: flex;
    gap: 4px;
}

.tool-form-js-runner .orj-tab {
    appearance: none;
    border: none;
    background: transparent;
    color: #888;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.tool-form-js-runner .orj-tab:hover {
    color: #1677ff;
    background: #eef5ff;
}

.tool-form-js-runner .orj-tab.is-active {
    color: #1677ff;
    background: #e6f4ff;
}

.tool-form-js-runner .orj-output {
    height: 240px;
    padding: 12px 14px;
    overflow: auto;
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.tool-form-js-runner .orj-log {
    margin: 0 0 4px;
}

.tool-form-js-runner .orj-log.is-info {
    color: #1677ff;
}

.tool-form-js-runner .orj-log.is-warn {
    color: #d48806;
}

.tool-form-js-runner .orj-log.is-error {
    color: #cf1322;
}

.tool-form-js-runner .orj-log.is-result {
    color: #722ed1;
    font-weight: 600;
}

.tool-form-js-runner .orj-log.is-muted {
    color: #999;
}

.tool-form-js-runner .orj-history-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(320px, calc(100% - 24px));
    display: none;
    flex-direction: column;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    z-index: 8;
    overflow: hidden;
}

.tool-form-js-runner .orj-workspace.is-history-open .orj-history-panel {
    display: flex;
}

.tool-form-js-runner .orj-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.tool-form-js-runner .orj-history-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.tool-form-js-runner .orj-history-title-main {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.tool-form-js-runner .orj-history-esc {
    color: #999;
    font-size: 11px;
    font-weight: 400;
}

.tool-form-js-runner .orj-history-title-sub {
    font-size: 11px;
    font-weight: 400;
    color: #999;
    line-height: 1.4;
}

.tool-form-js-runner .orj-history-title-sub #orj-history-count,
.tool-form-js-runner .orj-history-title-sub #orj-history-max {
    margin: 0 1px;
    color: #1677ff;
    font-weight: 500;
}

.tool-form-js-runner .orj-history-actions {
    display: flex;
    gap: 4px;
}

.tool-form-js-runner .orj-history-icon-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: #666;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.tool-form-js-runner .orj-history-icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tool-form-js-runner .orj-history-icon-btn:hover {
    background: #f0f0f0;
    color: #1677ff;
}

.tool-form-js-runner .orj-history-icon-btn[hidden] {
    display: none !important;
}

.tool-form-js-runner #orj-history-clear:hover {
    color: #ff4d4f;
    background: #fff1f0;
}

.tool-form-js-runner .orj-history-list {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
}

.tool-form-js-runner .orj-history-empty {
    padding: 24px 12px;
    text-align: center;
    color: #999;
    font-size: 13px;
    line-height: 1.6;
}

.tool-form-js-runner .orj-history-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.tool-form-js-runner .orj-history-main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    appearance: none;
    border: 1px solid #f0f0f0;
    background: #fff;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}

.tool-form-js-runner .orj-history-main:hover {
    border-color: #91caff;
    background: #f5faff;
}

.tool-form-js-runner .orj-history-title {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-form-js-runner .orj-history-meta {
    margin-top: 4px;
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-form-js-runner .orj-history-del {
    appearance: none;
    border: 1px solid transparent;
    background: #fff;
    color: #8c8c8c;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.tool-form-js-runner .orj-history-del svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tool-form-js-runner .orj-history-del:hover {
    color: #ff4d4f;
    background: #fff1f0;
}


.tool-form-js-runner .orj-editor-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    min-height: 0;
}

.tool-form-js-runner .orj-panel-editor {
    flex: 1;
    min-width: 0;
}

.tool-form-js-runner .orj-panel-io {
    width: 220px;
    flex-shrink: 0;
    padding: 10px;
    gap: 10px;
    box-sizing: border-box;
    background: #fafafa;
}

.tool-form-js-runner .orj-io-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tool-form-js-runner .orj-io-stdin {
    flex: 1;
    min-height: 0;
}

.tool-form-js-runner .orj-io-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.tool-form-js-runner .orj-io-input,
.tool-form-js-runner .orj-io-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    padding: 8px 10px;
    outline: none;
}

.tool-form-js-runner .orj-io-input:focus,
.tool-form-js-runner .orj-io-textarea:focus {
    border-color: #91caff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.tool-form-js-runner .orj-io-textarea {
    flex: 1;
    min-height: 180px;
    resize: vertical;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .tool-form-js-runner .orj-editor-row {
        flex-direction: column;
    }

    .tool-form-js-runner .orj-panel-io {
        width: 100%;
    }

    .tool-form-js-runner .orj-io-textarea {
        min-height: 120px;
    }
}

@media (max-width: 768px) {
    .tool-form-js-runner .orj-workspace {
        min-height: 0;
        padding: 8px;
    }

    .tool-form-js-runner .orj-editor-host {
        height: 240px;
    }

    .tool-form-js-runner .orj-output {
        height: 200px;
    }

    .tool-form-js-runner .orj-status {
        width: 100%;
        margin-left: 0;
    }
}
