:root {
  --bg: #f6f6f3; --panel: #ffffff; --text: #1c1c1a; --muted: #6a6a64; --line: #e1e0da; --accent: #2f5d8a;
  --accent-text: #ffffff; --ok: #2e7d4f; --warn: #9a5f0a; --bad: #a33a2b; --code: #f0efea;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151514; --panel: #1e1e1c; --text: #ebeae5; --muted: #a2a19a; --line: #33322e; --accent: #8db4dc;
          --accent-text: #10202f; --ok: #7cc79b; --warn: #e2b05a; --bad: #ec8b7d; --code: #292926; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, sans-serif; }
header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px;
         background: var(--panel); border-bottom: 1px solid var(--line); }
header h1 { margin: 0; font-size: 17px; }
header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.status { color: var(--muted); font-size: 12px; align-self: center; }
.status .status-link { font-size: inherit; padding: 0; }
/* Approvals: one request per row, its text clipped to two lines; the full payload is on hover and in Detail. */
.egress-table td:nth-child(1) { white-space: nowrap; }
.egress-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 70ch; }
nav { display: flex; gap: 4px; padding: 8px 16px 0; background: var(--panel); border-bottom: 1px solid var(--line);
      overflow-x: auto; }
nav button { border: 0; background: none; color: var(--muted); padding: 8px 12px; font: inherit; cursor: pointer;
             border-bottom: 2px solid transparent; }
nav button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab { max-width: 1100px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
         margin-bottom: 14px; overflow-x: auto; }
.panel h2 { margin: 0 0 6px; font-size: 15px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.help { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
td.mono, .mono { font-family: ui-monospace, monospace; font-size: 12px; }
td.wrap { overflow-wrap: anywhere; max-width: 420px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--code); }
button, .button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel);
                  color: var(--text); border-radius: 8px; padding: 4px 10px; cursor: pointer; display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 12px; align-items: end;
        margin-top: 8px; }
.grid label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.grid label:has(input[type="checkbox"]) { flex-direction: row; align-items: center; color: var(--text); }
.settings-form { align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.settings-form > label { min-width: 0; }
.field-with-help { position: relative; }
.field-tooltip { position: absolute; bottom: calc(100% + 6px); left: 0; width: 100%; padding: 8px 10px;
                 border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text);
                 box-shadow: 0 4px 12px #0002; font-size: 12px; z-index: 2; visibility: hidden; }
.field-with-help:hover .field-tooltip, .field-with-help:focus-within .field-tooltip { visibility: visible; }
.settings-form input:not([type="checkbox"]), .settings-form select { width: 100%; min-width: 0; height: 36px; }
.settings-form .form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end;
                               flex-wrap: wrap; gap: 8px 12px; }
.settings-form .form-actions > label { margin-right: auto; }
.settings-form .form-actions > button { min-height: 36px; }
#search-service-status { grid-column: 1 / -1; margin: 0; }
input, select, textarea { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
                          background: var(--bg); color: var(--text); }
.badge { border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; font-size: 11px; white-space: nowrap; }
.met, .ok { color: var(--ok); } .blocked, .bad { color: var(--bad); } .review, .warn { color: var(--warn); }
.detail, dialog pre { background: var(--code); padding: 10px; border-radius: 8px; overflow: auto; max-height: 60vh;
                      font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-box { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
dialog { max-width: min(960px, 95vw); width: 100%; border: 1px solid var(--line); border-radius: 12px;
         background: var(--panel); color: var(--text); }
.log { padding-bottom: 110px; }
.turn { margin: 14px 0; }
.you { text-align: right; }
.you span { display: inline-block; background: var(--accent); color: var(--accent-text); padding: 8px 12px;
            border-radius: 12px; max-width: 85%; text-align: left; white-space: pre-wrap; }
.lab { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.understood, .footer, .meta { color: var(--muted); font-size: 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.criterion { border-top: 1px solid var(--line); padding: 8px 0; }
.criterion:first-of-type { border-top: 0; }
.statement { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-cards { display: grid; gap: 12px; }
.computed-result { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.pending { color: var(--muted); font-style: italic; }
/* Running work takes at most three lines: its title and its two latest steps (the journey keeps them all). */
.chat-progress { padding: 4px 10px; border-left: 3px solid var(--accent); font-size: 12px; line-height: 20px; }
.chat-progress .help { margin: 0; font-size: 12px; }
.chat-progress-steps { margin: 0; padding-left: 24px; }
.chat-progress-steps li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-progress-steps li:nth-last-child(n+3) { display: none; }
.chat-progress-steps small { color: var(--muted); margin-left: 8px; }
.ask { position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line);
       padding: 10px 16px; display: flex; gap: 8px; }
.ask textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 60dvh; }
.toast { position: fixed; right: 16px; bottom: 80px; background: var(--text); color: var(--bg); padding: 8px 12px;
         border-radius: 8px; font-size: 13px; max-width: 80vw; }
@media (max-width: 640px) { th:nth-child(4), td:nth-child(4) { display: none; } }
.approval { margin-top: 10px; border: 1px solid var(--warn); border-radius: 10px; padding: 10px 12px; }
.approval-title { font-weight: 600; color: var(--warn); }
.approval .help { margin: 4px 0 6px; }
.approval-facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 0 0 8px;
                  font-size: 13px; }
.approval-facts dt { color: var(--muted); }
.approval-facts dd { margin: 0; overflow-wrap: anywhere; }

/* The journey shares the chat's width; collapsing it gives that space back to the conversation. */
body:has(#chat:not([hidden])) { height: var(--app-height, 100dvh); overflow: hidden; display: flex; flex-direction: column; }
body:has(#chat:not([hidden])) > header, body:has(#chat:not([hidden])) > nav { flex-shrink: 0; }
#chat { max-width: none; width: 100%; margin: 0; padding: 0; flex: 1; min-height: 0; display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0; align-items: stretch; }
#chat[hidden] { display: none; }
.chat-main { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; padding: 0 16px 16px; }
/* Attaching files is one wrapping row of at most three lines: the two buttons, the attached files and the status. */
.chat-file-controls { flex-shrink: 0; padding: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  max-height: 78px; overflow-y: auto; }
.chat-file-controls button { padding: 2px 8px; font-size: 12px; }
.chat-file-controls .help { margin: 0; font-size: 12px; }
.chat-file-controls .help:empty, #chat-files:empty { display: none; }
#chat-file-actions, #chat-files { gap: 4px 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 8px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; font-size: 12px; }
.file-chip span { min-width: 0; overflow-wrap: anywhere; }
.file-chip button { padding: 0 5px; }
.turn-files { margin-top: 6px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
#file-picker-dialog { max-height: 90dvh; overflow-y: auto; }
#file-picker-dialog h2 { font-size: 18px; }
.file-picker-filters { margin-bottom: 12px; }
#file-picker-rows td:first-child { overflow-wrap: anywhere; max-width: 400px; }
#file-picker-rows small { display: block; color: var(--muted); overflow-wrap: anywhere; }
#file-picker-dialog th:nth-child(4), #file-picker-dialog td:nth-child(4) { display: table-cell; }
#chat .log { flex: 1; min-height: 0; overflow-y: auto; padding-top: 8px; display: flex; flex-direction: column; }
#chat .log > .turn { flex-shrink: 0; }
#chat .log > .turn:first-child { margin-top: auto; }
#chat .log { padding-bottom: 16px; }
#chat .ask { position: relative; flex-shrink: 0; border: 1px solid var(--line); border-radius: 12px; padding: 16px 10px 10px; z-index: 1; }
#chat .ask > button { align-self: flex-end; min-height: 44px; }
#message-resize { position: absolute; top: 0; left: 10px; right: 10px; height: 16px;
                  cursor: ns-resize; touch-action: none; }
#message-resize::after { content: ''; display: block; width: 44px; height: 4px; margin: 5px auto;
                         border-radius: 4px; background: var(--muted); }
#message-resize:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
.journey { background: var(--panel); border-left: 1px solid var(--line); min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; }
#journey-toggle { flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; padding: 14px; background: transparent; font-weight: 600; text-align: left; }
#journey-toggle span { font-size: 22px; transform: rotate(90deg); }
#journey-body { flex: 1; min-height: 0; overflow: auto; padding: 0 14px 14px; }
.journey-controls { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.journey-controls label, .journey-stats { font-size: 12px; color: var(--muted); }
.journey-controls select { width: 100%; min-width: 0; }
.journey-controls .actions { flex-wrap: nowrap; }
#journey-task, #history-task { flex: 1; }
#chat.journey-collapsed { grid-template-columns: minmax(0, 1fr) 56px; }
.journey-collapsed #journey-body { display: none; }
.journey-collapsed #journey-toggle { writing-mode: vertical-rl; gap: 12px; }
.journey-collapsed #journey-toggle span { transform: rotate(180deg); }
.journey-title { font-size: 14px; margin: 12px 0 4px; overflow-wrap: anywhere; }
.journey-stats { margin-bottom: 12px; }
.journey-flow { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; color: var(--muted); padding: 10px 0; }
.journey-flow span { padding: 3px 6px; background: var(--code); border-radius: 5px; }
.journey-timeline { list-style: none; padding: 0 0 0 12px; margin: 8px 0; }
.journey-step { position: relative; border-left: 2px solid var(--line); padding: 0 0 14px 18px; }
.journey-step::before { content: ''; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); }
.journey-step:last-child { border-color: transparent; }
.journey-step[data-outcome="pass"]::before { background: var(--ok); }
.journey-step[data-outcome="fail"]::before { background: var(--bad); }
.journey-step summary { cursor: pointer; font-size: 13px; overflow-wrap: anywhere; }
.journey-step summary::marker { color: var(--muted); }
.journey-step .meta { font-size: 11px; overflow-wrap: anywhere; }
.journey-step .detail { max-height: 320px; margin: 8px 0; }
.journey-step .statement { font-size: 12px; margin: 6px 0; }
.journey-chart-viewport { max-width: 100%; overflow: auto; max-height: 65vh; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.journey-chart-dialog { position: fixed; inset: 0; z-index: 20; width: 100%; height: 100dvh; padding: 16px;
                        display: flex; flex-direction: column; gap: 8px; background: var(--panel); }
.journey-chart-dialog[hidden] { display: none; }
body.flowchart-expanded { overflow: hidden; }
.journey-chart-dialog h2 { margin: 0; font-size: 18px; }
.journey-chart-dialog > .help { margin: 0; }
#journey-chart-content { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.journey-chart-scale { position: relative; overflow: hidden; margin: 0 auto; }
/* The mounted view (timeline or flowchart host) scales from its top-left corner inside the sized wrapper. */
.journey-chart-scale > * { position: absolute; top: 0; left: 0; margin: 0; transform-origin: top left; }
.journey-chart-zoom { align-items: center; }
#journey-chart-zoom-label { min-width: 55px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.journey-step-list { list-style: none; padding: 0; margin: 12px 0; }
.journey-list-step { border: 0; padding: 0; }
.journey-list-step::before { display: none; }
.journey-step-list .journey-list-node { height: auto; min-height: 60px; border: 0; border-bottom: 1px solid var(--line);
                                      border-radius: 0; padding: 10px 4px; background: transparent; }
.journey-step-list .journey-list-node:hover { background: var(--code); }
.journey-readable-fields dt { font-weight: 600; text-transform: capitalize; margin-top: 12px; }
.journey-readable-fields dd { margin: 4px 0 8px 12px; overflow-wrap: anywhere; }
.journey-readable-fields p { white-space: pre-wrap; }
.journey-raw-details { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.journey-step-explanation h3 { margin-top: 0; }
.journey-node { display: flex; align-items: center; gap: 10px; width: 100%; height: 76px; padding: 10px 12px;
                text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--task-color); background: var(--panel); }
.journey-node:hover { background: var(--code); border-color: var(--task-color); }
.journey-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.journey-node-number { flex-shrink: 0; display: grid; place-items: center; width: 28px; height: 28px;
                       border-radius: 50%; background: var(--code); color: var(--muted); font-size: 11px; }
.journey-node-text { display: flex; flex-direction: column; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.journey-node-text strong { text-transform: capitalize; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.journey-node-agent { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.journey-node-status { font-size: 10px; color: var(--muted); }
.journey-step-dialog { max-height: 90dvh; }
.journey-step-dialog::backdrop { background: #0006; }
#journey-step-content { max-height: 65dvh; overflow: auto; margin: 12px 0; }
.journey-step-navigation { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.journey-step-navigation .help { margin: 0; }
.journey-task-tag { border-left: 3px solid var(--task-color, var(--line)); padding-left: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 900px) {
  #chat, #chat.journey-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .journey { grid-row: 1; height: auto; max-height: 40dvh; border-left: 0; border-bottom: 1px solid var(--line); }
  #journey-body { max-height: 30dvh; }
  .journey-collapsed #journey-toggle { writing-mode: horizontal-tb; }
  .journey-collapsed #journey-toggle span { transform: rotate(0); }
}
.chat-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 0; flex-shrink: 0; border-bottom: 1px solid var(--line); }
.chat-toolbar label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chat-toolbar select { flex: 1; min-width: 0; }
.chat-toolbar button { white-space: nowrap; }
@media (max-width: 640px) { .chat-toolbar label { display: none; } }
.journey-message { border-top: 1px solid var(--line); padding: 12px 0; }
.journey-message > summary { cursor: pointer; overflow-wrap: anywhere; font-size: 13px; }
.journey-message-label { font-weight: 650; margin-right: 8px; color: var(--accent); }
.journey-message-preview { color: var(--muted); display: -webkit-box; -webkit-box-orient: vertical;
                           -webkit-line-clamp: 2; overflow: hidden; margin-top: 4px; }
.journey-message[open] > summary .journey-message-preview { color: var(--text); }
.journey-message-body { padding-top: 6px; }
.journey-run + .journey-run { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 10px; }
.journey-run-label { color: var(--muted); font-size: 12px; margin: 0; }

#grok-search-options { grid-column: 1 / -1; min-width: 0; margin: 4px 0; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; }
#grok-search-options legend { padding: 0 6px; font-weight: 600; }
#grok-search-options .help { grid-column: 1 / -1; margin: 0; }
#grok-search-options[hidden], #search-results-field[hidden] { display: none; }

.agent-instructions-dialog { width: min(900px, 92vw); max-height: 90vh; overflow: auto; }
#agent-instructions-content textarea { display: block; width: 100%; box-sizing: border-box; font-family: monospace; margin: .5rem 0; resize: vertical; }

.agent-save-actions { justify-content: flex-end; align-items: center; margin-top: 12px; }
.corpus-source { border-top: 1px solid var(--line); padding: 10px 0; }
.corpus-source > summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.corpus-source table { margin-top: 8px; table-layout: fixed; }
.corpus-source th:first-child { width: 32%; }
.corpus-source th:nth-child(2), .corpus-source th:nth-child(3) { width: 70px; }
.corpus-source th:last-child { width: 90px; }
.agent-save-actions .help { margin: 0; }
.recipe-metadata { overflow-wrap: anywhere; }
.recipe-metadata dt { font-weight: 600; }
.recipe-metadata dd { margin: 0 0 10px; white-space: pre-wrap; }

.agent-layer th { padding: 5px 8px; font-size: 14px; line-height: 1.4; color: var(--accent-text); background: var(--accent); }
.agent-group th { padding: 4px 8px; font-size: 12px; line-height: 1.4; color: var(--accent);
                  background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.agent-name small { display: block; max-width: 28rem; margin-top: 3px; font-weight: normal; }

.scientist-examples { margin-top: 6px; font-size: 12px; max-width: 30rem; }
.scientist-examples summary { cursor: pointer; color: var(--accent); }
.scientist-examples ul { margin: 6px 0; padding-left: 18px; }

.answer-explanation { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.answer-explanation h3 { margin: 0 0 8px; font-size: 14px; }
.answer-explanation p { margin: 8px 0; white-space: pre-wrap; }

.chat-toolbar { flex-wrap: wrap; }
.chat-toolbar #chat-harness { flex: 0 1 190px; }
.harness-help { margin: 8px 0; flex-shrink: 0; }
.chat-identity { margin: 0 0 8px; flex-shrink: 0; overflow-wrap: anywhere; user-select: text; }
.harness-pair { border-top: 1px solid var(--line); padding: 12px 0; }
.table-scroll { overflow-x: auto; }
.benchmark-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 18px; }
.benchmark-result { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.benchmark-result h3 { margin: 0; }
.benchmark-answer, .benchmark-question-summary p { white-space: pre-wrap; overflow-wrap: anywhere; }
.benchmark-answer { line-height: 1.55; margin: 16px 0; }
.benchmark-error { color: var(--bad); overflow-wrap: anywhere; }
.benchmark-harness { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; }
.benchmark-harness input { margin-top: 4px; }
.benchmark-harness small { display: block; margin-top: 4px; }
#benchmark-question { display: block; width: 100%; margin: 8px 0 16px; min-height: 140px; resize: vertical; }
#benchmark-harnesses { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; }
#benchmark-history { max-width: 100%; margin: 8px 0; }
#benchmark button:disabled { opacity: .5; cursor: not-allowed; }

.fact-confirmation, .confirmed-premises { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; }
.fact-confirmation blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding-left: 12px; white-space: pre-wrap; }
.fact-confirmation textarea { width: 100%; box-sizing: border-box; margin: 6px 0; }

#suite-subsets, #suite-harnesses { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 14px 0; border: 1px solid var(--line, #ddd); border-radius: 8px; }
.suite-subset { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; max-width: 100%; overflow-wrap: anywhere; }
.suite-subset input { width: auto; }
.suite-subset small { flex-basis: 100%; }
.suite-result { border-top: 1px solid var(--line, #ddd); margin-top: 12px; padding-top: 12px; overflow-wrap: anywhere; }
.suite-result pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 400px; overflow-y: auto; font-size: 12px; }
.table-scroll { overflow-x: auto; }
#suite-results h3 { font-size: 14px; }

#suite-question-preview { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 400px; overflow-y: auto; font-size: 12px; }
#suite-question-select { width: 100%; min-width: 0; }
.suite-history-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.suite-history-controls[hidden] { display: none; }
.suite-history-controls label { flex: 1 1 260px; min-width: 0; max-width: 720px; display: flex; flex-direction: column; gap: 4px; }
.suite-history-controls input, .suite-history-controls select { width: 100%; min-width: 0; }
.suite-history-controls button { min-height: 35px; }
#agent-history { max-width: 1600px; width: 100%; }
#agent-history .table-scroll { margin: 12px 0; }
#agent-history-table { min-width: 1150px; }
#agent-history-table thead { position: sticky; top: 0; background: var(--panel); z-index: 1; }
#agent-history-table td { overflow-wrap: anywhere; }
#agent-history-table .history-sort { border: 0; padding: 0; color: inherit; font-weight: 600; background: none; text-align: left; }
.agent-history-question { min-width: 160px; max-width: 300px; }
.agent-history-question small { display: block; }
#agent-history-filters { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
#agent-history-filters input, #agent-history-filters select { min-width: 0; width: 100%; }
#journeys { max-width: 1600px; width: 100%; }
#query-history-filters { grid-template-columns: repeat(auto-fit,minmax(min(190px,100%),1fr)); }
#query-history-filters input, #query-history-filters select { width: 100%; min-width: 0; }
#query-history-table { min-width: 1300px; }
#query-history-table td { overflow-wrap: anywhere; max-width: 280px; }
#query-history-table .history-sort { border: 0; padding: 0; background: none; color: inherit; font-weight: 600; text-align: left; }
.query-history-question { min-width: 220px; max-width: 350px; }
.query-history-question .link { text-align: left; }
.query-history-question small { display: block; }
.query-history-columns { margin: 12px 0; }
#query-history-columns { gap: 8px 16px; padding-top: 8px; }
#query-history-columns label { display: flex; align-items: center; gap: 5px; }
.query-history-metadata { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 4px 16px; font-size: 13px; }
.query-history-metadata dt { color: var(--muted); }
.query-history-metadata dd { margin: 0; overflow-wrap: anywhere; }

.running-chat-card { cursor: pointer; }
.running-chat-card:hover { outline: 1px solid #aac1d9; outline-offset: 3px; }

.downloaded-collection { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.downloaded-collection h3 { margin: 0 0 8px; font-size: 15px; }
.downloaded-filters { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.downloaded-filters label { flex: 1 1 180px; min-width: 0; }
.downloaded-filters input, .downloaded-filters select { display: block; width: 100%; margin-top: 5px; box-sizing: border-box; }
.downloaded-pages { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.downloaded-archived { display: block; margin-top: 4px; color: var(--muted, #666); }
#downloaded-datasets td { vertical-align: top; }
#downloaded-datasets td:first-child { min-width: 220px; }
#downloaded-datasets details { min-width: 110px; max-width: 360px; }
#downloaded-datasets details[open] { min-width: 260px; }
.downloaded-files { padding-left: 18px; font-size: 12px; overflow-wrap: anywhere; }
.downloaded-files small { display: block; }
#downloaded-datasets td:nth-child(6), #downloaded-datasets td:nth-child(7), #downloaded-datasets td:nth-child(8) { white-space: nowrap; }

/* Each step-list node carries a workflow stage and honest per-operation metrics. */
.journey-node { height: 156px; align-items: flex-start; padding: 12px; }
.journey-node-metrics { display: flex; flex-direction: column; margin-top: 5px; font-size: 10px; color: var(--muted); }
.journey-node-metrics span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.journey-workflow-badge { color: var(--accent); font-weight: 700; padding: 8px 12px; background: var(--code); border-radius: 6px; }
.journey-inspection-metrics { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr); gap: 6px 16px; }
.journey-inspection-metrics dt { font-weight: 600; }
.journey-inspection-metrics dd { margin: 0; overflow-wrap: anywhere; }
.journey-data-block pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; padding: 12px; background: var(--code); border-radius: 6px; }
.journey-isolated-test { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 24px 0; }
.journey-test-controls { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin-bottom:12px; }
.journey-test-controls label { min-width:0; }
.journey-test-controls label[hidden] { display:none; }
.journey-test-controls select { width:100%; min-width:0; height:36px; }
.journey-test-actions { align-items:center; }
.journey-test-actions button { min-height:36px; }
#default-model-form { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
#default-model-form select, #default-model-form input, #default-model-form > button { min-height:36px; }
#default-reasoning-status, #default-model-status { grid-column:1 / -1; margin:0; }
.journey-step-test-result { margin-top: 16px; }
.journey-artifact { margin:8px 0; border:1px solid var(--line); border-radius:8px; padding:8px 12px; }
.journey-artifact summary { cursor:pointer; font-weight:600; }
.journey-artifact > a { display:inline-block; margin-top:6px; font-size:12px; }
.journey-artifact pre { max-height:320px; }
.journey-ranks { width: 100%; table-layout: fixed; font-size: 12px; }
.journey-ranks td, .journey-ranks th { overflow-wrap: anywhere; vertical-align: top; }
@media (max-width: 600px) { .journey-inspection-metrics { grid-template-columns: 1fr; } .journey-inspection-metrics dd { margin-bottom: 8px; } }

.dataset-source-group th { text-align: left; background: color-mix(in srgb, var(--accent) 7%, var(--panel)); color: var(--accent); padding: 9px 8px; }
.data-visibility { font-weight: 600; white-space: nowrap; }
.data-visibility.private { color: var(--accent); }
.dataset-labels { min-width: 135px; }
.dataset-labels[open] { min-width: 240px; }
.dataset-labels label { display: block; margin: 9px 0; }
.dataset-labels input, .dataset-labels select { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; }
.journey-step-review { margin:18px 0; padding:16px; border:1px solid var(--line); border-radius:10px; }
.journey-step-review label { display:block; margin:12px 0; }
.journey-step-review select,.journey-step-review textarea { display:block; width:100%; box-sizing:border-box; margin-top:5px; }
.agent-reasoning-note { display:block; max-width:240px; margin-top:4px; }
/* The Models page is wide enough for an agent's effort and output limit to sit on one line. */
#models { max-width: 1600px; width: 100%; }
.agent-limits { display:grid; grid-template-columns:220px 210px; gap:4px 10px; align-items:start; }
.agent-limits .help { margin:0; max-width:none; }
.agent-limits input { width:100%; box-sizing:border-box; }
@media (max-width: 900px) { .agent-limits { grid-template-columns:1fr; } }
.journey-recovery-notice { padding:12px 16px; border:1px solid var(--ok); border-radius:8px; margin:12px 0; }
.journey-recovery-notice h3 { margin-top:0; color:var(--ok); }
.login-page { min-height:100vh; display:grid; place-items:center; padding:20px; }
.login-panel { width:100%; max-width:440px; margin:auto; }
.login-panel label { display:block; margin:18px 0; }
.login-panel input { display:block; width:100%; margin-top:6px; }
.login-panel button { margin:8px 8px 0 0; }
#account-controls[hidden] { display:none; }
.flow-revision { margin:16px 0; padding:14px; border:1px solid var(--line); border-radius:8px; }
.quality-suggestion { border-left:3px solid var(--accent); padding-left:12px; margin:14px 0; }

/* The workflow is the first heading on every presentation of a recorded step. */
.journey-node { flex-direction: column; height: 200px; gap: 8px; }
.journey-node-body { display: flex; align-items: flex-start; gap: 10px; width: 100%; min-width: 0; }
.journey-workflow-heading { margin: 0; width: 100%; min-width: 0; font-size: 13px; line-height: 1.3; text-align: left; white-space: normal; overflow-wrap: anywhere; text-transform: none; }
.journey-node > .journey-workflow-heading { padding: 6px 8px; font-size: 11px; flex-shrink: 0; }
.journey-step-list .journey-list-node { gap: 8px; }
.journey-step-dialog > .panel-head { align-items: flex-start; }
.journey-step-dialog .panel-head .journey-workflow-heading { flex: 1; padding: 10px 12px; font-size: 17px; }
.journey-event-heading { margin: 10px 0 0; color: var(--muted); font-weight: 600; }
.chat-progress-steps .journey-workflow-heading { display: inline; margin: 0 8px 0 0; padding: 0 6px; font-size: 12px; }
#agent-history-table .journey-workflow-heading { min-width: 180px; padding: 6px 8px; font-size: 12px; }

#app-info-toggle, #chat-details-toggle, #chat-attachments-toggle { display: none; }
@media (max-width: 900px) {
  header { padding: 4px 10px; gap: 4px 8px; align-items: center; }
  header > div:first-child { flex: 1; min-width: 0; }
  header h1 { font-size: 15px; }
  header #app-description, header #status, header #account-controls { display: none; }
  #app-info-toggle { display: block; min-height: 40px; }
  header.mobile-details-open { max-height: 35dvh; overflow-y: auto; }
  header.mobile-details-open #app-description { display: block; }
  header.mobile-details-open #status { display: block; flex-basis: 100%; }
  header.mobile-details-open #account-controls:not([hidden]) { display: flex; flex-basis: 100%; align-items: center; }
  #account-name { min-width: 0; overflow-wrap: anywhere; }
  nav { padding: 0 6px; min-height: 44px; gap: 0; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex-shrink: 0; min-height: 44px; white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  #chat, #chat.journey-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .chat-main { padding: 0 10px max(8px, env(safe-area-inset-bottom)); }
  .journey { grid-column: 1; grid-row: 1; max-height: 35dvh; }
  .journey-collapsed .journey { height: 42px; }
  #journey-toggle { min-height: 42px; padding: 8px 12px; font-size: 13px; }
  .journey-collapsed #journey-toggle { writing-mode: horizontal-tb; }
  .chat-toolbar { padding: 4px 0; gap: 6px; }
  .chat-toolbar label { display: none; }
  .chat-toolbar #new-chat { order: 1; min-height: 40px; padding: 4px 8px; }
  .chat-toolbar #saved-chats { order: 2; flex: 1; min-width: 0; min-height: 40px; }
  #chat-details-toggle { order: 3; display: block; min-height: 40px; padding: 4px 8px; }
  .chat-toolbar #chat-harness, #harness-help, #chat-identity { display: none; }
  #chat.chat-details-open #chat-harness { display: block; order: 4; flex: 1 1 100%; min-height: 40px; }
  #chat.chat-details-open #harness-help, #chat.chat-details-open #chat-identity { display: block; max-height: 64px; overflow-y: auto; }
  #chat .log { padding: 4px 0 8px; }
  .turn { margin: 8px 0; }
  .lab { padding: 10px; }
  .answer-cards { min-width: 0; }
  .chat-file-controls { padding: 4px 0; gap: 4px; }
  #chat-attachments-toggle { display: block; min-height: 40px; text-align: left; }
  .chat-file-controls:not(.attachments-open) #chat-file-actions,
  .chat-file-controls:not(.attachments-open) #chat-files,
  .chat-file-controls:not(.attachments-open) #chat-files-status { display: none; }
  .chat-file-controls button { min-height: 36px; }
  #chat-files { max-height: 56px; }
  #chat-files:empty { display: none; }
  #chat .ask { padding: 14px 8px 8px; }
  #chat .ask textarea, input, select { font-size: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  dialog { max-width: calc(100vw - 16px); max-height: 90dvh; }
  body.chat-keyboard-open:has(#chat:not([hidden])) > header,
  body.chat-keyboard-open:has(#chat:not([hidden])) > nav,
  .chat-keyboard-open #journey, .chat-keyboard-open .chat-toolbar,
  .chat-keyboard-open #harness-help, .chat-keyboard-open #chat-identity { display: none !important; }
  .chat-keyboard-open #chat, .chat-keyboard-open #chat.journey-collapsed { grid-template-rows: minmax(0, 1fr); }
}
/* The "Timeline" and "Flowchart" buttons, and the full page's view switch ("Timeline | Flowchart"). */
.journey-view-controls { align-items: center; margin-bottom: 6px; }
.journey-view-switch { display: inline-flex; }
.journey-view-switch button { border-radius: 0; margin-left: -1px; }
.journey-view-switch button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.journey-view-switch button:last-child { border-radius: 0 8px 8px 0; }
.journey-view-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.journey-view-switch button:disabled { color: var(--muted); cursor: not-allowed; }

.statement.formatted > p { margin: 0 0 8px; }
.statement.formatted > p:last-child { margin-bottom: 0; }
.statement-list { margin: 4px 0 10px; padding-left: 22px; }
.statement-list li { margin: 0 0 6px; }
.record-ref { padding: 0 1px; font: inherit; text-decoration: underline; }
.source-panel { margin: 8px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-alt, rgba(127,127,127,.06)); }
.source-card { padding: 8px 0; border-top: 1px solid var(--line); }
.source-card:first-of-type { border-top: 0; }
.source-quote { margin: 6px 0; padding: 2px 10px; border-left: 3px solid var(--line); font-style: italic; }
.source-quote.contradicts { border-left-color: #b3261e; }
.source-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Figure evidence (core/figures.js): a value read from a figure image, with its caption and transcription. */
.figure-evidence { margin: 8px 0; }
.figure-card { margin: 8px 0; padding: 8px 0; border-top: 1px solid var(--line); }
.figure-card:first-of-type { border-top: 0; }
.figure-image { display: block; max-width: 100%; max-height: 420px; margin: 6px 0; border: 1px solid var(--line); background: #fff; }
.figure-caption { margin: 4px 0; }
.figure-transcription q { font-family: var(--code, monospace); }
