/* Shared components for both pages. Page markup owns state, this file owns appearance. */
:root {
    color-scheme: light;
    --font-ui: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-controls: Arial, sans-serif;
    --font-code: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --canvas: #f6f7f8;
    --surface: #fff;
    --soft: #f2f3f4;
    --header: #646464;
    --ink: #303436;
    --muted: #62676b;
    --subtle: #747a7f;
    --line: #d4d8dc;
    --line-strong: #b9c0c6;
    --link: #2a6478;
    --blue-soft: #edf4f6;
    --accent: #ffdd2d;
    --accent-hover: #ffea61;
    --accent-ink: #424242;
    --selected: #fff8d5;
    --selected-line: #e4cf79;
    --positive: #267345;
    --positive-soft: #eaf5ee;
    --negative: #b13c35;
    --negative-soft: #fbeeed;
    --warning: #93651c;
    --warning-soft: #fff4df;
    --violet: #72549b;
    --violet-soft: #f1ecf8;
    --radius-panel: .725rem;
    --radius-control: .375rem;
    --radius-inset: .5rem;
    --radius-badge: .25rem;
    --space-panel: 16px;
    --shadow-panel: 0 2px 6px #0000001a;
}

/* Typography and page frame */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { min-height: 100vh; background: var(--canvas); color: var(--ink); font: 400 16px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--link); flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
[hidden], .hidden, .collapsed { display: none !important; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 12px max(32px, calc((100vw - 1376px) / 2)); background: var(--header); color: #fff; box-shadow: 0 2px 6px #0002; }
.brand { color: #fff; font-size: 24px; font-weight: 400; letter-spacing: -.025em; }
.brand:hover { text-decoration: none; }
.brand::after { content: "."; color: var(--accent); font-weight: 700; }
.user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; }
header .btn-secondary { border-color: #fff; }
.site-header { display: block; min-height: 0; padding: 0; }
.site-header-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    width: min(100%, 1440px);
    min-height: 62px;
    padding-inline: 32px;
    margin: auto;
    gap: 24px;
}
.site-navigation { display: flex; min-width: 0; align-items: stretch; gap: 20px; }
.site-navigation a {
    display: flex;
    align-items: center;
    min-height: 62px;
    border-bottom: 2px solid transparent;
    color: white;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}
.site-navigation a:hover { color: var(--accent-hover); text-decoration: none; }
.site-navigation a[aria-current] { border-bottom-color: var(--accent); }
.site-navigation a:focus-visible, .site-header .brand:focus-visible { outline-color: var(--accent); }
.site-header .user-info { min-width: 0; max-width: min(38vw, 360px); }
.site-header #username { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-header .user-info button { flex: none; }
.context-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; font-size: 13px; }
.context-links a { min-width: 0; overflow-wrap: anywhere; }
.context-links > span { color: var(--muted); }
@media (max-width: 740px) {
    .site-header-inner { grid-template-columns: auto minmax(0, 1fr); gap: 0 12px; padding: 8px 16px 0; }
    .site-header .user-info { grid-column: 2; grid-row: 1; justify-content: flex-end; max-width: none; }
    .site-navigation { grid-column: 1 / -1; grid-row: 2; gap: clamp(10px, 4vw, 20px); }
    .site-navigation a { min-height: 42px; font-size: 13px; }
}
.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 32px 32px; }
.main-content { width: 100%; min-width: 0; }
.problems-header, .problem-info { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.problems-header h2, .problem-info h2 { font-size: 24px; font-weight: 700; line-height: 1.3; letter-spacing: -.025em; overflow-wrap: anywhere; }
.problem-heading-main { min-width: 0; }
.problem-meta { margin-top: 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.draft-header-badge { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.draft-indicator-dot { display: none; }
.page-actions, .button-group, .editor-actions, .version-actions, .workspace-tools, .stmt-block-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.muted, .field-help, .row-meta { color: var(--muted); font-size: 12px; }
.subtle { color: var(--subtle); }
.field-help { margin-top: 8px; }
.field-help + .form-group { margin-top: 16px; }
.row-title { font-weight: 600; }
.code-label { font-family: var(--font-code); font-size: 12px; }
.empty-state, .loading { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-state h2, .empty-state h3 { color: var(--ink); font-size: 18px; font-weight: 500; margin-bottom: 8px; }
.empty-state p { margin-bottom: 16px; }

/* Controls */
.btn, .stmt-add-block { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 36px; padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); font: 600 16px/1.25 var(--font-controls); text-decoration: none; cursor: pointer; }
.btn:hover, .stmt-add-block:hover { background: var(--soft); text-decoration: none; }
.btn-primary, .btn-success { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover, .btn-success:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); }
.btn-danger { color: var(--negative); }
.btn-danger:hover { background: var(--negative-soft); border-color: var(--negative); }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.form-input, .form-select, .form-group input:not([type="checkbox"]):not([type="radio"]), .form-group select { width: 100%; min-width: 0; min-height: 36px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); font: 14px/1.5 var(--font-ui); }
.form-input:focus, .form-select:focus, .form-group input:focus, .form-group select:focus { border-color: var(--link); }
.contest-sort { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.contest-sort .btn { min-width: 40px; padding-inline: 8px; }
.contest-sort label { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.contest-pages { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; text-align: center; }
.contest-pages span { font-size: 13px; color: var(--muted); }
.contest-pages .btn { min-width: 38px; padding-inline: 8px; }
.form-group { margin-bottom: 16px; }
.form-group label, .field-label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 13px; font-weight: 600; }
.form-row { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.form-row .form-input { width: 96px; }
.checkbox-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.field-section { margin-top: 16px; }
.form-group input[type="file"] { padding: 4px; }
input::file-selector-button { min-height: 30px; margin-right: 8px; padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--soft); color: var(--ink); font: inherit; cursor: pointer; }
#testArgsInput { font-family: var(--font-code); font-size: 12px; }

/* Shared white surfaces and their headers */
.panel, .search-bar, .file-workspace, #problemsList { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); box-shadow: var(--shadow-panel); }
.panel { min-width: 0; padding: var(--space-panel); margin-bottom: 20px; }
.panel-header, .statement-build-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin: calc(-1 * var(--space-panel)) calc(-1 * var(--space-panel)) var(--space-panel); padding: 16px var(--space-panel); border-bottom: 1px solid var(--line); border-radius: var(--radius-panel) var(--radius-panel) 0 0; background: #fafafa; }
.panel-title, .workspace-pane-header h3 { color: var(--ink); font-size: 18px; font-weight: 700; line-height: 1.5; }
.panel-header > div { min-width: 0; }
.panel .panel { box-shadow: none; }
#cellArtifactsPanel { margin-top: 20px; }
.search-bar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: var(--space-panel); margin-bottom: 20px; }
.search-field { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 140px; color: var(--muted); font-size: 12px; font-weight: 600; }
.search-field:first-child { flex: 2; }
.search-actions { display: flex; gap: 8px; }
#searchInfo { margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.search-match { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.search-match span { font-weight: 600; }
.problems-table mark { padding: 0 2px; border-radius: 2px; background: var(--selected); color: var(--ink); }
#pagination { gap: 12px; align-items: center; margin-top: 20px; }
#importStatus { margin-bottom: 16px; color: var(--muted); font-size: 13px; }

/* Navigation and selection use the same selected state */
.problem-nav, .tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius-inset); background: var(--surface); overflow-x: auto; }
.nav-item, .tab { flex: 0 0 auto; min-height: 36px; padding: 7px 16px; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--muted); font: 400 16px/1.5 var(--font-ui); white-space: nowrap; cursor: pointer; }
.nav-item:hover, .tab:hover { background: var(--soft); color: var(--ink); }
.nav-item.active, .tab.active { border-color: var(--selected-line); background: var(--selected); color: var(--accent-ink); font-weight: 600; }

/* Tables: one header, row spacing and border treatment */
.table-scroll, #testsTable, #problemsList { width: 100%; overflow-x: auto; }
#problemsList:empty { display: none; }
#testsTable:has(table), .matrix-scroll { border: 1px solid var(--line); border-radius: var(--radius-inset); }
table { border-collapse: collapse; }
.problems-table, .data-table, .run-table { width: 100%; background: var(--surface); font-size: 13px; }
.problems-table th, .data-table th, .run-table th { padding: 12px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
.problems-table td, .data-table td { padding: 12px; border-top: 1px solid var(--line); text-align: left; }
.problems-table tbody tr:hover, .data-table tbody tr:hover { background: #fafafa; }
.problems-table .problem-link { font-weight: 600; }
@media (max-width: 600px) {
    #problemsList { overflow: visible; }
    #problemsList .problems-table, #problemsList .problems-table tbody { display: block; width: 100%; }
    #problemsList .problems-table thead { display: none; }
    #problemsList .problems-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px; border-top: 1px solid var(--line); }
    #problemsList .problems-table td { min-width: 0; padding: 0; border: 0; }
    #problemsList .problems-table td:nth-child(1) { grid-column: 2; grid-row: 1; color: var(--muted); }
    #problemsList .problems-table td:nth-child(2) { grid-column: 1; grid-row: 1; overflow-wrap: anywhere; font-size: 15px; }
    #problemsList .problems-table td:nth-child(3), #problemsList .problems-table td:nth-child(4) { grid-column: 1 / -1; }
    #problemsList .problems-table td:nth-child(5) { grid-column: 1; color: var(--muted); }
    #problemsList .problems-table td:nth-child(6) { grid-column: 2; justify-self: end; }
    #problemsList .problems-table td:nth-child(4)::before { content: 'Tags: '; color: var(--muted); }
    #problemsList .problems-table td:nth-child(5)::before { content: 'Updated '; }
}
.data-table .test-number { font-weight: 600; }
.data-table .test-detail { min-width: 280px; max-width: 640px; font: 12px/1.6 var(--font-code); overflow-wrap: anywhere; }
.data-table .test-actions, .data-table .test-sample, .data-table .text-center { text-align: center; }
.data-table .button-group { flex-wrap: nowrap; }
.data-table tr[data-editable] { cursor: pointer; }
#testsTable { overflow-x: auto; }
.test-editor-dialog { inset: 0; margin: auto; width: min(600px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); color: var(--ink); box-shadow: 0 12px 48px #0003; }
.test-editor-dialog::backdrop { background: #25252585; }
.test-editor-header, #testEditorBody, .test-editor-footer { padding: 16px clamp(14px, 4vw, 22px); }
.test-editor-header { border-bottom: 1px solid var(--line); }
.test-editor-header h3 { font-size: 18px; }
#testEditorBody, #testSourceBody { display: grid; gap: 14px; }
.test-editor-metadata { display: grid; grid-template-columns: minmax(72px, 96px) minmax(0, 1fr); gap: 12px; }
#testSourceBody { padding-top: 14px; border-top: 1px solid var(--line); }
.test-editor-field-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.test-editor-field-head .field-label { margin: 0; }
.test-editor-input { display: block; min-height: 136px; max-height: 46dvh; overflow: auto; resize: vertical; font: 13px/1.55 var(--font-code); white-space: pre; }
.test-editor-footer { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); background: #fafafa; }
.test-editor-footer .muted { flex: 1 1 150px; margin-right: auto; }
.run-table th, .run-table td { min-width: 130px; padding: 8px 12px; border: 1px solid var(--line); text-align: center; }
.run-table thead th { position: sticky; top: 0; z-index: 2; max-width: 200px; overflow-wrap: anywhere; }
.run-table tr > :first-child { position: sticky; left: 0; min-width: 80px; background: var(--soft); z-index: 1; }
.run-table thead tr > :first-child { z-index: 3; }
.matrix-scroll { max-height: 65vh; overflow: auto; }
.verdict-button { width: 100%; min-height: 36px; padding: 2px; border: 0; background: transparent; font: 600 12px/1.5 var(--font-ui); }
.verdict-button small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.verdict-ok { color: var(--positive); }
.verdict-wa, .verdict-tl, .verdict-ml, .verdict-pe { color: var(--warning); }
.verdict-re, .verdict-ce, .verdict-fail { color: var(--negative); }

/* Badges share a scale and shape; color carries meaning */
.owner-badge, .tag, .status-badge, .file-type-badge, .stmt-block-badge, .draft-indicator, .item-count { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 1px solid var(--line); border-radius: var(--radius-badge); background: var(--soft); color: var(--muted); font: 500 11px/1.4 var(--font-ui); white-space: nowrap; }
.tag { margin-right: 4px; color: var(--link); }
.file-type-badge { font-size: 10px; text-transform: uppercase; }
.status-running, .file-type-generator { background: var(--blue-soft); border-color: #ccdfe5; color: var(--link); }
.status-pending, .file-type-validator, .draft-indicator { background: var(--warning-soft); border-color: #ead6ad; color: var(--warning); }
.status-failed { background: var(--negative-soft); border-color: #e9c6c3; color: var(--negative); }
.status-completed, .file-type-solution { background: var(--positive-soft); border-color: #c9e0d0; color: var(--positive); }
.file-type-test { background: #fff0e5; border-color: #eed7c2; color: #9a5722; }
.file-type-statement { background: var(--violet-soft); border-color: #ddd2ed; color: var(--violet); }
.stmt-block-badge { background: var(--surface); }

/* File workspace */
.file-workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); height: min(680px, calc(100dvh - 292px)); min-height: 520px; overflow: hidden; }
.repository-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.workspace-pane-header, .editor-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; min-height: 64px; padding: 16px var(--space-panel); border-bottom: 1px solid var(--line); background: #fafafa; }
.workspace-pane-header h3 { display: flex; align-items: center; gap: 8px; }
.workspace-tools { gap: 6px; }
#filesTree { flex: 1; min-height: 0; overflow: auto; padding: 8px; }
.files-tree { font: 13px/1.5 var(--font-ui); }
.file-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.file-item:last-child { border-bottom: 0; }
.file-item-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.file-item-name { color: var(--link); overflow-wrap: anywhere; }
.file-item-actions { display: flex; flex-shrink: 0; gap: 6px; }
.file-open { display: flex; align-items: center; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.file-open:hover .file-item-name { text-decoration: underline; }
.dir-item { display: flex; align-items: center; width: 100%; padding: 8px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); font: 600 13px/1.5 var(--font-ui); text-align: left; }
.dir-item::before { content: '▾'; margin-right: 8px; color: var(--subtle); }
.dir-item[aria-expanded="false"]::before { content: '▸'; }
.dir-item:hover { background: var(--soft); }
.dir-children { margin-left: 10px; padding-left: 6px; border-left: 1px solid var(--line); }
#filesTree .file-item { min-height: 36px; padding: 0 6px; border: 1px solid transparent; border-radius: var(--radius-control); }
#filesTree .file-open { width: 100%; min-height: 34px; gap: 6px; padding: 4px 0; }
#filesTree .file-item-name { color: #424b50; font: 12px/1.6 var(--font-code); }
#filesTree .file-type-badge { padding: 1px 4px; font-size: 9px; }
#filesTree .file-item:hover { background: var(--soft); }
#filesTree .file-item.selected { background: var(--selected); border-color: var(--selected-line); }
#filesTree .file-item.selected .file-item-name { color: var(--link); }
.workspace-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.workspace-welcome { flex: 1; min-height: 0; overflow: auto; }
.workspace-welcome-body { padding: var(--space-panel); }
.workspace-hint { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.editor-panel { display: flex; flex-direction: column; flex: 1; height: 100%; min-height: 0; overflow: hidden; }
.editor-header { flex: 0 0 auto; }
.editor-title { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink); font: 12px/1.6 var(--font-code); }
.editor-actions { gap: 6px; }
.editor { width: 100%; min-height: 160px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); resize: vertical; tab-size: 4; font: 13px/1.65 var(--font-code); }
#testInputContent { margin-top: 8px; }
.editor-status { display: flex; justify-content: space-between; flex: 0 0 auto; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line); background: #fafafa; color: var(--muted); font-size: 11px; }
#fileEditorLanguage { white-space: nowrap; }
.code-editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 46px minmax(0, 1fr); background: var(--surface); }
.code-editor .editor { height: 100%; min-height: 0; padding: 16px; margin: 0; border: 0; border-radius: 0; outline: none; resize: none; overflow: auto; white-space: pre; font: 13px/22px var(--font-code); }
.line-numbers { height: 100%; padding: 16px 10px; border-right: 1px solid var(--line); background: #fafafa; color: var(--subtle); text-align: right; overflow: hidden; user-select: none; font: 13px/22px var(--font-code); }
.code-editor.has-code-editor { display: block; overflow: hidden; }
.has-code-editor > .line-numbers, .has-code-editor > textarea { display: none; }
.code-editor .cm-editor { height: 100%; background: var(--surface); color: #26374a; font-size: 13px; }
.code-editor .cm-scroller { overflow: auto; font-family: var(--font-code); line-height: 22px; }
.code-editor .cm-content { padding: 14px 0; caret-color: var(--ink); }
.code-editor .cm-line { padding: 0 16px 0 12px; }
.code-editor .cm-gutters { border-right: 1px solid var(--line); background: #fafafa; color: var(--subtle); }
.code-editor .cm-gutterElement { padding-right: 8px; }
.code-editor .cm-activeLine, .code-editor .cm-activeLineGutter { background: #fffbed; }
.code-editor .cm-focused { outline: none; }
.code-editor .cm-cursor { border-left-color: var(--ink); }
.code-editor .cm-focused .cm-selectionBackground, .code-editor .cm-selectionBackground { background: #dce9f7; }
.code-editor .cm-selectionMatch { background: #e8f0e9; }
.code-editor .cm-matchingBracket { background: #dfeee3; outline: 1px solid #a5c9af; }
.code-editor .cm-panels { background: var(--soft); color: var(--ink); font: 12px/1.5 var(--font-ui); }
.code-editor .cm-textfield, .code-editor .cm-button { border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); }

/* The configuration form and source share one document and save action. */
.manifest-editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.manifest-editor.manifest-source { flex: 0 0 auto; }
.manifest-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafafa; }
.manifest-modes { display: flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.manifest-modes button { padding: 5px 14px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--muted); font: 13px/1.4 var(--font-controls); }
.manifest-modes button[aria-pressed="true"] { border-color: var(--selected-line); background: var(--selected); color: var(--ink); }
.manifest-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); min-height: 0; flex: 1; }
.manifest-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px 8px; border-right: 1px solid var(--line); overflow: auto; background: #fafafa; }
.manifest-nav button { padding: 9px 10px; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--muted); text-align: left; font: 13px/1.5 var(--font-controls); }
.manifest-nav button:hover { background: var(--soft); }
.manifest-nav button[aria-current="true"] { border-color: var(--selected-line); background: var(--selected); color: var(--ink); }
.manifest-form { padding: 20px; min-width: 0; overflow: auto; }
.manifest-form h3 { font-size: 17px; margin-bottom: 18px; }
.manifest-form h4 { font-size: 14px; margin-bottom: 4px; }
.manifest-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.manifest-fields .form-group { margin: 0; min-width: 0; }
.manifest-fields .field-help { display: block; margin-top: 5px; }
.manifest-notice { padding: 10px 14px; border-bottom: 1px solid var(--selected-line); background: var(--warning-soft); color: var(--warning); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--font-code); max-height: 140px; overflow: auto; }
.manifest-bindings { margin-top: 24px; }
.manifest-bindings:first-of-type { margin-top: 0; }
.manifest-bindings .field-help { margin-bottom: 10px; }
.manifest-catalog-note { margin-bottom: 20px; }
.manifest-catalog-defaults { margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius-inset); }
.manifest-catalog-defaults summary { padding: 9px 11px; cursor: pointer; font-size: 13px; }
.manifest-catalog-defaults summary:hover { background: var(--soft); }
.manifest-catalog-defaults table { width: 100%; table-layout: fixed; text-align: left; font-size: 12px; }
.manifest-catalog-defaults th, .manifest-catalog-defaults td { padding: 6px 11px; border-top: 1px solid var(--line); vertical-align: top; }
.manifest-catalog-defaults th:first-child { width: 35%; }
.manifest-catalog-defaults thead { color: var(--muted); background: var(--soft); }
.manifest-catalog-defaults code { font-family: var(--font-code); font-weight: 400; overflow-wrap: anywhere; }
.manifest-binding-head, .manifest-binding-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 30px; gap: 8px; margin-bottom: 8px; align-items: center; }
.manifest-binding-head { color: var(--muted); font-size: 11px; }
.manifest-binding-row input { min-width: 0; font: 12px/1.5 var(--font-code); }
.manifest-binding-row [data-remove-binding] { min-width: 0; padding-inline: 0; font-size: 18px; }
.manifest-related { display: grid; gap: 8px; margin-top: 18px; }
.manifest-related-link { display: flex; justify-content: space-between; gap: 16px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--link); text-align: left; font-size: 13px; }
.manifest-related-link:hover { border-color: var(--line-strong); background: var(--blue-soft); }
.scoring-groups-head, .scoring-group-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}
.scoring-groups-head { margin-bottom: 12px; }
.scoring-groups-head h4 { font-size: 16px; margin: 0; }
.scoring-groups-list { list-style: none; display: grid; gap: 10px; }
.scoring-group {
    display: grid;
    gap: 10px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.scoring-group-head h4 { margin: 0; overflow-wrap: anywhere; }
.scoring-group-points { flex: 0 0 auto; color: var(--warning); background: var(--warning-soft); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 5px; }
.scoring-group dl { display: grid; gap: 6px; font-size: 13px; }
.scoring-group dl > div { display: grid; grid-template-columns: minmax(56px, 73px) minmax(0, 1fr); gap: 10px; align-items: baseline; }
.scoring-group dt { color: var(--muted); }
.scoring-group dd { overflow-wrap: anywhere; }
.scoring-group-ranges { font-variant-numeric: tabular-nums; }
.scoring-group details summary { color: var(--link); cursor: pointer; }
.scoring-group details span { display: block; margin-top: 4px; }
.scoring-group-dependency { display: inline; padding: 1px 4px; background: var(--blue-soft); color: var(--link); border-radius: 4px; }
.scoring-group-edit { justify-self: start; border: 0; padding: 3px 0; background: transparent; font-size: 13px; color: var(--link); text-align: left; }
.scoring-group-edit:hover { text-decoration: underline; }
.scoring-groups-empty { background: var(--soft); padding: 12px 14px; border-radius: 8px; color: var(--muted); font-size: 13px; }
@media (max-width: 1100px) {
    .manifest-body { grid-template-columns: 125px minmax(0, 1fr); }
    .manifest-fields { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    .manifest-body { display: flex; flex-direction: column; }
    .manifest-nav { flex-direction: row; flex-shrink: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
    .manifest-nav button { white-space: nowrap; padding: 8px; }
    .manifest-form { padding: 16px; }
    .manifest-toolbar > .field-help { display: none; }
    .manifest-binding-head, .manifest-binding-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 28px; gap: 5px; }
}

/* Statement editing and build results */
.statement-tools, .statement-language, .statement-build-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.statement-language label { color: var(--muted); }
.statement-language .form-select { width: auto; }
.statement-build-header .field-help { margin-top: 4px; }
.statement-build-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; }
.statement-build-row > a { margin-left: auto; }
.statement-build-row pre { flex-basis: 100%; color: var(--negative); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--font-code); }
.statement-editor-panel { display: block; height: auto; }
.panel > .editor-header { margin: calc(-1 * var(--space-panel)) calc(-1 * var(--space-panel)) var(--space-panel); border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
#statementEditorBody { min-height: 0; }
.stmt-block { margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius-inset); overflow: hidden; background: var(--surface); }
.stmt-block-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafafa; cursor: pointer; user-select: none; }
.stmt-block-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; color: var(--ink); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.stmt-block-actions { flex-shrink: 0; gap: 4px; }
.stmt-block textarea { display: block; width: 100%; min-height: 120px; padding: 12px 16px; border: 0; background: var(--surface); resize: vertical; font: 13px/1.65 var(--font-code); }
.stmt-block .stmt-title-textarea { min-height: 64px; }
.stmt-add-block { border-style: dashed; font-weight: 500; }

/* Histories and result details */
.run-summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 20px 0 12px; font-size: 13px; }
.run-summary h4 { font-size: 14px; font-weight: 600; }
.run-history { display: flex; flex-direction: column; max-height: 240px; border: 1px solid var(--line); border-radius: var(--radius-inset); overflow: auto; }
.run-history .run-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 12px; border: 0; border-left: 3px solid transparent; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; font: 13px/1.5 var(--font-ui); }
.run-history .run-row:last-child { border-bottom: 0; }
.run-history .run-row:hover { background: var(--soft); }
.run-history .run-row[aria-pressed="true"] { border-left-color: var(--accent); background: var(--selected); }
.run-row small { color: var(--muted); }
.run-row .status-badge { margin-right: 8px; }
.version-row, .commit-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.version-row:last-child, .commit-row:last-child { border-bottom: 0; }
.version-info, .row-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.version-details { flex: 1 1 19rem; min-width: 0; }
.version-comment { margin-top: 5px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.commit-row { display: block; }
.commit-row > div + div { margin-top: 4px; }
#commitsList { max-height: 400px; overflow: auto; }
.artifact-block { padding: 16px 0; border-bottom: 1px solid var(--line); }
.artifact-block:last-child { border-bottom: 0; }
.artifact-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.artifact-block pre { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-inset); background: var(--canvas); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--font-code); }
.change-added { border-left: 3px solid var(--positive); padding-left: 12px; }
.change-modified { border-left: 3px solid var(--warning); padding-left: 12px; }
.change-deleted { border-left: 3px solid var(--negative); padding-left: 12px; }
.task-row { border-left: 3px solid var(--line); padding-left: 12px; }
.task-completed { border-left-color: var(--positive); }
.task-failed { border-left-color: var(--negative); }
.task-running { border-left-color: var(--link); }
.task-pending { border-left-color: var(--warning); }

/* Dialogs and feedback use the same controls and surface rules */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; background: #0006; }
.problems-page .modal-overlay { display: none; }
.problems-page .modal-overlay.active { display: flex; }
.modal { width: min(100%, 560px); min-width: 0; max-height: calc(100dvh - 48px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: 0 12px 48px #0003; }
.modal h3, .modal-title { margin-bottom: 20px; color: var(--ink); font-size: 20px; font-weight: 500; line-height: 1.4; }
.modal-actions, .form-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
body.modal-open { overflow: hidden; }
.selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.selection-heading button { min-height: 32px; padding: 4px 8px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--link); font: 600 13px/1.5 var(--font-controls); }
.selection-heading button:hover { background: var(--soft); }
.selection-list { max-height: 180px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-inset); }
.selection-list label { display: flex; align-items: center; gap: 8px; min-height: 32px; color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.form-error, .run-error, .result-item, .warning-box { padding: 12px 16px; margin: 16px 0; border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: var(--radius-inset); background: var(--canvas); font: 13px/1.6 var(--font-ui); overflow-wrap: anywhere; }
.form-error, .run-error, .result-error { border-left-color: var(--negative); background: var(--negative-soft); color: var(--negative); }
.form-error:empty { display: none; }
.warning-box { border-left-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.result-success { border-left-color: var(--positive); background: var(--positive-soft); color: var(--positive); }
.result-info { border-left-color: var(--link); background: var(--blue-soft); }
.run-error pre { margin-top: 8px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--font-code); }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: start; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-inset); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-panel); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.toast-error { border-left-color: var(--negative); }
.toast button { padding: 0 3px; border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.skip-link { position: absolute; left: 12px; top: -100px; z-index: 3000; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.skip-link:focus { top: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.compact-row { padding: 6px 0; }
.compact-actions { display: inline-flex; gap: 6px; margin-left: 8px; }
.back-action { margin-bottom: 20px; }

@media (max-width: 1100px) {
    .file-workspace { grid-template-columns: 300px minmax(0, 1fr); }
    .workspace-pane-header, .editor-header { padding-inline: 16px; }
    .workspace-pane-header { gap: 8px; }
    .editor-title { flex-basis: 100%; }
}
@media (max-width: 900px) {
    :root { --space-panel: 16px; }
    header { padding: 12px 16px; }
    .container { padding: 20px 16px 24px; }
    .problems-header h2, .problem-info h2 { font-size: 23px; }
    .problem-info { align-items: flex-start; gap: 12px; margin-bottom: 20px; }
    .problem-info > .btn { margin-left: auto; }
    .problem-nav { margin-bottom: 20px; }
    .nav-item { padding-inline: 12px; }
    .file-workspace { display: flex; flex-direction: column; height: auto; min-height: 0; }
    .repository-pane { border-right: 0; border-bottom: 1px solid var(--line); }
    #filesTree { max-height: 280px; flex: auto; }
    .editor-panel { height: 540px; flex: auto; }
    .editor-header { align-items: flex-start; }
    .editor-title { flex-basis: 100%; }
    .editor-actions { width: 100%; justify-content: flex-end; }
    .statement-build-header .statement-tools, .statement-language, .statement-build-actions { width: 100%; }
    .statement-language .form-select { flex: 1; }
    .statement-build-actions .btn { flex: 1; }
    .search-field { min-width: calc(50% - 8px); }
    .search-field:first-child { min-width: 100%; }
    .modal-overlay { padding: 16px; }
    .modal { max-height: calc(100dvh - 32px); padding: 20px; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
    .file-item { align-items: flex-start; flex-wrap: wrap; }
    .statement-sources .file-item-info { flex-basis: 100%; }
    .stmt-block-header { padding: 12px; gap: 8px; }
    .stmt-block-actions .btn { padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* Tests of checking programs share the workspace's forms and panels. */
.tool-kind { margin-bottom: 12px; }
.tool-workspace { display: grid; grid-template-columns: minmax(190px, 240px) minmax(0, 1fr); gap: 20px; }
.tool-workspace > aside { border-right: 1px solid var(--line); padding-right: 16px; }
.tool-workspace > div { min-width: 0; }
.tool-test-row { width: 100%; display: flex; justify-content: space-between; text-align: left; gap: 8px; padding: 10px 8px; border: 1px solid transparent; border-radius: var(--radius-control, 6px); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.tool-test-row.selected { background: #fff7c7; border-color: #e7c935; }
.tool-fixtures { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tool-fixture { min-height: 220px; resize: vertical; font-family: monospace; white-space: pre; tab-size: 4; }
.tool-comment { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 650px; max-height: 320px; overflow: auto; }
.sharing-modal { width: min(100%, 680px); }
.sharing-form { display: grid; gap: 8px; margin: 20px 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sharing-form .field-hint { margin: 0 0 8px; }
.sharing-form > .btn { justify-self: start; }
.sharing-member { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sharing-identity { display: grid; gap: 3px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sharing-member .form-select { width: auto; max-width: 190px; }
.statement-preview iframe { display: block; width: 100%; min-height: 70vh; margin-top: 16px; border: 1px solid var(--line); background: white; }
.draft-conflict-note { margin: 16px 0 8px; }
.draft-conflict { margin: 12px 0; padding: 16px; border: 1px solid #bd943b; background: #fffdf4; }
.draft-conflict h4 { margin: 0 0 12px; overflow-wrap: anywhere; }
.draft-conflict summary { cursor: pointer; margin-bottom: 12px; }
.draft-comparison { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.draft-comparison > div { min-width: 0; }
.draft-comparison h5 { margin: 0 0 8px; }
.draft-comparison pre { overflow: auto; max-height: 340px; padding: 12px; background: white; border: 1px solid var(--line); font-size: 12px; }
.draft-conflict .button-group { margin-top: 12px; }
.saved-draft-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.saved-draft-row > div { min-width: 0; overflow-wrap: anywhere; }
.saved-draft-row button { flex-shrink: 0; }
@media (max-width: 760px) {
    .draft-comparison { grid-template-columns: minmax(0, 1fr); }
    .saved-draft-row { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
    .sharing-member { flex-wrap: wrap; }
    .sharing-identity { flex-basis: 100%; }
    .sharing-member .form-select { flex: 1; max-width: none; }
}
@media (max-width: 700px) {
    .tool-workspace { grid-template-columns: minmax(0, 1fr); }
    .tool-workspace > aside { border-right: 0; padding-right: 0; border-bottom: 1px solid #ddd; padding-bottom: 12px; }
}
