:root {
  color-scheme: light;
  --bg: #f6f5f1; --surface: #ffffff; --ink: #1d1c1a; --muted: #6b675f; --line: #dcd8cf;
  --accent: #1f5f8b; --accent-ink: #ffffff; --sd: #1f7a5a; --fr: #7a4b1f;
  --ok-bg: #e2f2e9; --ok-ink: #17583f; --run-bg: #e6eef7; --run-ink: #1f4b75;
  --bad-bg: #f9e3e1; --bad-ink: #8a2a20; --bar: #d6e6f2; --bar-top: #1f5f8b;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #151514; --surface: #1e1e1c; --ink: #ecebe7; --muted: #a39f96; --line: #3a3934;
    --accent: #6fb0e0; --accent-ink: #0d1a24;
    --ok-bg: #173327; --ok-ink: #8fe0b8; --run-bg: #1a2a3b; --run-ink: #9cc6ee;
    --bad-bg: #3a1c19; --bad-ink: #f2a79c; --bar: #2a3c4b; --bar-top: #6fb0e0;
    --sd: #74d3aa; --fr: #e6b07a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .01em; }
main { padding: 16px 20px 40px; }
#signed-in { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(360px, 7fr); gap: 20px; align-items: start; }
#signed-in[hidden], [hidden] { display: none !important; }
@media (max-width: 900px) { #signed-in { grid-template-columns: 1fr; } }

.task { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.modes { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; align-self: flex-start; }
.modes button { border: 0; background: transparent; color: var(--ink); padding: 7px 16px; font: inherit; font-weight: 550; cursor: pointer; }
.modes button + button { border-left: 1px solid var(--line); }
.modes button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.modes button:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, legend { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
textarea, input { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
textarea { resize: vertical; font-size: 14px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
legend { padding: 0; margin-bottom: 4px; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: minmax(90px, 2fr) 5fr auto; gap: 6px; }
.row .name { font-family: var(--mono); font-size: 13px; }
.inline { display: flex; gap: 10px; }
.inline .grow { flex: 1; }
.inline .field:not(.grow) { width: 110px; }
.image-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file { position: relative; display: inline-flex; padding: 5px 12px; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 14px; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file:focus-within { outline: 2px solid var(--accent); }
#image-preview { max-height: 56px; max-width: 120px; border-radius: 4px; border: 1px solid var(--line); }
#image-name { font-size: 13px; color: var(--muted); }
.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 2px 6px; align-self: flex-start; }
.actions { display: flex; align-items: center; gap: 12px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 8px 26px; font: inherit; font-weight: 650; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: progress; }
.error { color: var(--bad-ink); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-weight: 400; }

.results { overflow-x: auto; }
#results { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; table-layout: fixed; }
#results caption { caption-side: top; text-align: left; font-weight: 650; padding: 0 0 8px; min-height: 1.45em; }
#results th, #results td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
#results thead th { font-size: 13px; }
#results thead th:nth-child(1) { width: 22%; }
#results thead th:nth-child(2) { color: var(--sd); }
#results thead th:nth-child(3) { color: var(--fr); }
#results tbody th { font-weight: 550; color: var(--muted); font-size: 13px; }
#results tr.sub th { font-family: var(--mono); font-weight: 400; padding-left: 18px; }
#results tr.prose td { white-space: pre-wrap; }
.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12.5px; font-weight: 600; text-transform: capitalize; }
.status.completed { background: var(--ok-bg); color: var(--ok-ink); }
.status.running { background: var(--run-bg); color: var(--run-ink); text-transform: none; }
.status.failed, .status.timed_out { background: var(--bad-bg); color: var(--bad-ink); }
.prob { display: flex; align-items: center; gap: 8px; }
.prob .bar { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--bar-top) calc(var(--p) * 100%), var(--bar) 0); max-width: 160px; }
.prob .num { font-family: var(--mono); font-size: 13px; min-width: 52px; }
.prob.top .num { font-weight: 700; }
.entities { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.entities .value { font-weight: 550; }
.entities .muted { font-family: var(--mono); font-size: 12px; }
