/* 新版编程工作台桌面布局：压缩留白并限制可视边界，保留原有图标和文字字号。 */
.workbench-file-submit-modal[hidden], .workbench-file-submit-modal [hidden] { display: none !important; }
.workbench-file-submit-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .48);
}
.workbench-file-submit-dialog {
    width: 560px;
    max-width: 100%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 24px;
    border: 1px solid #dce1e8;
    border-radius: 12px;
    background: #fff;
    color: #263445;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .2);
}
.workbench-file-submit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.workbench-file-submit-header h2 { margin: 0; font-size: 20px; font-weight: 600; }
.workbench-file-submit-header button { border: 0; padding: 0 6px; background: transparent; color: inherit; font-size: 28px; line-height: 1; }
.workbench-file-submit-problem { margin-bottom: 16px; overflow-wrap: anywhere; }
.workbench-file-submit-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 28px 16px;
    border: 2px dashed #b8c7d8;
    border-radius: 8px;
    background: #f7faff;
    color: inherit;
    cursor: pointer;
}
.workbench-file-submit-drop > .glyphicon { color: #337ab7; font-size: 28px; }
.workbench-file-submit-drop.is-dragging, .workbench-file-submit-drop:focus { border-color: #337ab7; background: #edf5ff; }
.workbench-file-submit-muted { margin-top: 12px; color: #677689; font-size: 13px; line-height: 1.6; }
.workbench-file-submit-selected { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px; border-radius: 6px; background: #f2f5f9; }
.workbench-file-submit-selected[hidden] { display: none; }
#workbench-file-submit-filename { flex: 1 1 180px; overflow-wrap: anywhere; font-weight: 600; }
.workbench-file-submit-selected .workbench-file-submit-muted { margin: 0; }
.workbench-file-submit-error { color: #b42318; margin-top: 14px; overflow-wrap: anywhere; }
.workbench-file-submit-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.workbench-file-submit-modal button:disabled { cursor: default; opacity: .6; }
[data-theme="dark"] .workbench-file-submit-dialog { background: #1f2937; color: #e5e7eb; border-color: #4b5563; }
[data-theme="dark"] .workbench-file-submit-drop, [data-theme="dark"] .workbench-file-submit-selected { background: #111827; border-color: #64748b; }
[data-theme="dark"] .workbench-file-submit-muted { color: #adbace; }
[data-theme="dark"] .workbench-file-submit-error { color: #fca5a5; }

.workbench-page.is-compact-workbench {
    bottom: auto;
    height: max(0px, calc(var(--workbench-viewport-height, 100dvh) - var(--workbench-navbar-height)));
    padding-bottom: 0;
}

.workbench-page.is-compact-workbench.is-exam-workbench {
    height: max(0px, calc(var(--workbench-viewport-height, 100dvh) - var(--workbench-navbar-height) - var(--exam-workbench-topbar-height)));
}

.workbench-left-page.is-compact-workbench {
    /* 题面插件会改写 body 高度，滚动区直接以 iframe 的可视高度为边界。 */
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

.is-compact-workbench .workbench-left-toolbar {
    padding-top: 8px;
}

.is-compact-workbench .workbench-left-nav {
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding-top: 6px;
    padding-bottom: 8px;
}

.is-compact-workbench .workbench-font-scale {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    flex: 1 0 auto;
    gap: 6px;
    margin-left: auto;
    padding-left: 8px;
    color: var(--workbench-left-text, #444);
    font-size: 12px;
    white-space: nowrap;
}

.workbench-font-scale label {
    margin: 0;
    font-weight: normal;
}

.workbench-font-scale input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 90px;
    height: 12px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.workbench-font-scale input[type="range"]::-webkit-slider-runnable-track {
    height: 2px;
    border: 0;
    background: var(--workbench-left-border, #d9d9d9);
}

.workbench-font-scale input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    margin-top: -4px;
    border: 0;
    border-radius: 50%;
    background: #fa514c;
    box-shadow: none;
}

.workbench-font-scale input[type="range"]::-moz-range-track {
    height: 2px;
    border: 0;
    background: var(--workbench-left-border, #d9d9d9);
}

.workbench-font-scale input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: 0;
    border-radius: 50%;
    background: #fa514c;
    box-shadow: none;
}

.workbench-font-scale input:focus-visible {
    outline: 2px solid #fa514c;
    outline-offset: 3px;
}

.workbench-font-scale output {
    display: block;
    flex: 0 0 36px;
    margin: 0;
    padding: 0;
    color: inherit;
    font-size: 12px;
    line-height: 16px;
    text-align: right;
}

.is-compact-workbench .workbench-left-nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
    justify-content: center;
    padding: 4px 10px;
    line-height: 20px;
}

.is-compact-workbench .workbench-description-limits {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 12px;
    color: var(--workbench-left-muted, #666);
    font-size: 14px;
    line-height: 20px;
}

.is-compact-workbench .workbench-description-limits span {
    white-space: nowrap;
}

.is-compact-workbench .workbench-description-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 20px 0 8px;
    padding-top: 12px;
    border-top: 1px solid var(--workbench-left-border, #e5e7eb);
}

.is-compact-workbench .workbench-description-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 9px;
    border: 1px solid var(--workbench-left-border, #d9dee5);
    border-radius: 999px;
    background: var(--workbench-left-surface-muted, #f4f6f8);
    color: var(--workbench-left-text, #4b5563);
    font-size: 13px;
    line-height: 18px;
    overflow-wrap: anywhere;
}

.is-compact-workbench .workbench-description-tag.is-primary {
    border-color: #fa541c;
    background: #fa541c;
    color: #fff;
    font-weight: 600;
}

.is-compact-workbench .workbench-code-actions {
    position: absolute;
    top: 5px;
    right: 6px;
    display: flex;
    gap: 6px;
    line-height: 20px;
}

.is-compact-workbench .workbench-code-actions button {
    position: static;
    padding: 1px 7px;
    border: 1px solid var(--workbench-left-border, #ccc);
    border-radius: 3px;
    background: var(--workbench-left-surface-muted, #f0f0f0);
    color: var(--workbench-left-text, #444);
    font-family: inherit;
    font-size: 12px;
    line-height: 20px;
    cursor: pointer;
    opacity: .85;
}

.is-compact-workbench .workbench-code-actions button:hover,
.is-compact-workbench .workbench-code-actions button:focus-visible {
    opacity: 1;
}

.is-compact-workbench .workbench-left-nav-item .glyphicon {
    top: 0;
}

.is-compact-workbench .workbench-right-editor {
    /* 小窗口下允许收缩，避免旧的 320px 下限把按钮和分隔条推出屏幕。 */
    min-height: 0;
    padding-top: 6px;
    padding-bottom: 4px;
    padding-left: 0;
}

.is-compact-workbench .workbench-editor-shell {
    gap: 4px;
}

/* 桌面窄窗口仍采用可拖动的两栏，不套用旧的触屏按钮高度。 */
@media (min-width: 761px) {
    .is-compact-workbench .workbench-shell {
        grid-template-columns: minmax(360px, var(--workbench-left-width)) 10px minmax(520px, 1fr);
    }
}

/* 旧题目样式固定了工具栏高度，并给图标附加内边距，需要同时清除。 */
.is-compact-workbench .workbench-right-editor #code_tool_bar {
    height: auto;
    padding: 0;
}

.is-compact-workbench .workbench-right-editor #code_tool_bar .btn.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 0;
    height: 28px;
}

.is-compact-workbench .workbench-right-editor #code_tool_bar .editor_tool_btn,
.is-compact-workbench .workbench-right-editor #code_tool_bar .editor_tool_refresh_btn {
    top: 0 !important;
    padding: 0;
}

.is-compact-workbench .workbench-editor-actions {
    flex-wrap: nowrap;
    gap: 6px 8px;
    padding: 0;
}

.is-compact-workbench .workbench-submission-summary {
    display: flex;
    flex: 1 1 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    min-width: 0;
}

.is-compact-workbench .workbench-submit-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.is-compact-workbench .workbench-problem-limits {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    gap: 2px 12px;
    margin-right: auto;
    color: #666;
    font-size: 14px;
    line-height: 20px;
}

.is-compact-workbench .workbench-problem-limits span {
    white-space: nowrap;
}

.is-compact-workbench .workbench-editor-actions .btn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 104px;
    min-height: 0;
    height: 28px;
    padding: 3px 12px;
    line-height: 20px;
}

.is-compact-workbench .workbench-editor-actions .glyphicon {
    top: 0 !important;
}

/* 状态区只显示短提示，详细状态节点留给结果弹窗，不能挤动右侧按钮。 */
.is-compact-workbench #submit-code-status-block.workbench-inline-submit-status {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100px;
    height: 28px;
    margin: 0 !important;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 13px;
    line-height: 20px;
    text-align: left;
    white-space: nowrap;
}

.is-compact-workbench .workbench-inline-submit-status .submit-code-status-value {
    display: none !important;
}

.is-compact-workbench .workbench-inline-submit-status img {
    flex: 0 0 auto;
}

.is-compact-workbench #submit-code-test-progress {
    color: #64748b;
}

.is-compact-workbench .workbench-compile-log {
    display: none !important;
}

/* 底部只保留输入、输出两列，标签与收起按钮共用一行。 */
.is-compact-workbench .workbench-status-panel {
    padding: 8px 16px 8px 12px;
    gap: 0;
}

.is-compact-workbench .workbench-right-bottom #run-code-status-block {
    flex: 1 1 0;
    min-height: 0;
}

.is-compact-workbench .workbench-right-bottom #run-code-status-block .panel-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "input-label output-label" "input output";
    gap: 6px 12px;
}

.is-compact-workbench .workbench-right-bottom #run-code-status-block .panel-body::before,
.is-compact-workbench .workbench-right-bottom #run-code-status-block .panel-body::after {
    display: none;
}

.is-compact-workbench .workbench-output-label {
    grid-area: output-label;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.is-compact-workbench #run-code-status-value-id {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 400;
}

.is-compact-workbench .workbench-output-label > :first-child,
.is-compact-workbench .workbench-output-label img,
.is-compact-workbench .workbench-collapse-btn {
    flex: 0 0 auto;
}

.is-compact-workbench .workbench-collapse-btn {
    margin-left: auto;
}

.is-compact-workbench .workbench-right-bottom #run-code-stdin,
.is-compact-workbench .workbench-right-bottom #run-code-stdout {
    /* 失败样例回填仍会写入旧版自适应高度，以当前网格高度为准。 */
    height: 100% !important;
    max-height: none;
    margin-bottom: 0;
    padding: 6px 10px !important;
}

[data-theme="dark"] .is-compact-workbench .workbench-problem-limits {
    color: #c4ccd5;
}

[data-theme="dark"] .is-compact-workbench .workbench-output-label,
[data-theme="dark"] .is-compact-workbench #submit-code-test-progress {
    color: #c4ccd5;
}
