/* Jobsearcher web UI. Hand-written, no framework; light and dark via prefers-color-scheme. */
:root {
  --bg: #fafaf8; --fg: #1d1d1b; --muted: #6b6b66; --line: #e2e1dc; --card: #fff;
  --accent: #2456a6; --good: #1f7a3d; --warn: #9a6400; --bad: #b3261e; --chip: #efeee9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171716; --fg: #e8e7e2; --muted: #9a9993; --line: #33332f; --card: #1f1f1d;
    --accent: #8ab4f8; --good: #6ccf8e; --warn: #e3b35c; --bad: #f28b82; --chip: #2a2a27;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 0.2em 0; }
h2 { font-size: 1.1rem; margin: 1.4em 0 0.4em; border-bottom: 1px solid var(--line); }
code { font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }

/* Header and budget widget */
.top {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--card);
}
.top nav { display: flex; gap: 16px; align-items: baseline; }
.brand { font-weight: 700; color: var(--fg); }
.budget { display: flex; gap: 10px; align-items: center; font-size: 0.85em; color: var(--muted); }
.bar { position: relative; width: 140px; height: 8px; background: var(--chip); border-radius: 4px; }
.bar .fill { height: 100%; background: var(--good); border-radius: 4px; max-width: 100%; }
.bar .fill.warn { background: var(--warn); }
.bar .fill.over { background: var(--bad); }
.bar .marker { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--fg); }

/* Filter form */
form.filters {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end;
  padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
form.filters label { display: flex; flex-direction: column; font-size: 0.8em; color: var(--muted); }
form.filters label.check { flex-direction: row; gap: 4px; align-items: center; }
input, select, textarea, button {
  font: inherit; font-size: 0.95em; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px;
}
input[type=number] { width: 5.5em; }
button { cursor: pointer; }
button.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* Job table */
table.jobs { width: 100%; border-collapse: collapse; font-size: 0.92em; }
table.jobs th { text-align: left; font-weight: 600; color: var(--muted); white-space: nowrap; }
table.jobs th, table.jobs td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.jobs tr:hover td { background: var(--chip); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score { display: inline-block; min-width: 2.2em; text-align: center; border-radius: 4px; font-weight: 600; }
.score.top { background: var(--good); color: var(--bg); }
.chip {
  display: inline-block; padding: 0 6px; border-radius: 9px; background: var(--chip);
  font-size: 0.8em; white-space: nowrap; color: var(--fg);
}
.chip.new { background: var(--accent); color: var(--bg); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.good { color: var(--good); }

/* Job page */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; margin: 8px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.button {
  display: inline-block; padding: 5px 12px; border-radius: 4px;
  background: var(--accent); color: var(--bg); font-weight: 600;
}
.adtext { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); padding: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 32px; }
ul.tight { margin: 0.2em 0; padding-left: 1.2em; }
.tracking textarea { width: 100%; min-height: 4em; }
.tracking .states { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

/* Settings */
.editor textarea {
  width: 100%; min-height: 60vh; font: 13px/1.4 ui-monospace, "SFMono-Regular", Menlo, monospace;
  tab-size: 2; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.editor-cols { align-items: start; }
.example pre {
  max-height: 70vh; overflow: auto; margin: 6px 0 0; padding: 10px; font-size: 12px;
  background: var(--card); border: 1px solid var(--line);
}
.result { margin: 8px 0; padding: 8px 12px; border-radius: 4px; border: 1px solid var(--line); }
.result.ok { border-color: var(--good); }
.result.error { border-color: var(--bad); color: var(--bad); }
form.upload { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin: 12px 0 4px; }
form.upload label { display: flex; flex-direction: column; font-size: 0.85em; color: var(--muted); }
button.danger { color: var(--bad); border-color: var(--bad); }

/* Structured settings forms */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px 14px; margin: 0 0 12px;
}
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }  /* one category per line */
.link-card { display: flex; flex-direction: column; gap: 4px; color: var(--fg); }
.link-card:hover { border-color: var(--accent); text-decoration: none; }
.link-card span { color: var(--muted); font-size: 0.9em; }
.settings-form label { display: flex; flex-direction: column; gap: 3px; margin: 0 0 10px; font-weight: 600; font-size: 0.92em; }
.settings-form label.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; max-width: 360px; font-weight: 400; }
.settings-form label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.settings-form textarea { width: 100%; font-weight: 400; resize: vertical; }
.settings-form input:not([type=checkbox]):not([type=number]):not([type=search]) { width: 100%; font-weight: 400; }
.help { font-weight: 400; font-size: 0.85em; color: var(--muted); }
p.help { margin: 0 0 8px; }
.grid2, .grid3 { display: grid; gap: 0 16px; }
/* Option boxes stack, one per line (the names are kept for grouping in the markup). */
.grid2, .grid3 { grid-template-columns: 1fr; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 8px; }
fieldset.plain legend { font-weight: 600; margin-bottom: 6px; }
.role-head { display: flex; gap: 12px; align-items: end; }
.role-head .grow { flex: 1; }
.role details summary { cursor: pointer; color: var(--muted); margin-bottom: 6px; }
button.link { background: none; border: 0; padding: 4px; color: var(--accent); }
button.link.danger { color: var(--bad); }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.savebar {
  position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  padding: 10px 0; margin-top: 8px; background: var(--bg); border-top: 1px solid var(--line);
}
.savebar #form-result { flex: 1 1 100%; }
.savebar .result { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 8px 0; }
.toolbar input[type=search] { min-width: 240px; }
.table-scroll { overflow-x: auto; }
table.edit td { vertical-align: middle; padding: 3px 4px; }
table.edit input { width: 100%; padding: 2px 4px; }
table.edit .w-name { min-width: 11em; }
table.edit .w-url { min-width: 14em; }
table.edit .w-loc { min-width: 7em; }
table.edit .w-tags { min-width: 10em; }
table.edit td.center { text-align: center; }
table.edit tr.off input:not([type=checkbox]) { color: var(--muted); }
details.more summary { cursor: pointer; color: var(--accent); font-size: 0.85em; white-space: nowrap; }
details.more[open] .more-fields {
  position: absolute; z-index: 5; right: 16px; width: min(460px, 90vw); padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 16px #0003;
}
.more-fields label { font-weight: 600; font-size: 0.85em; }
.pair { display: flex; gap: 6px; }

/* Sortable column headers */
table.jobs th a.sort { color: var(--muted); white-space: nowrap; }
table.jobs th a.sort:hover { color: var(--accent); text-decoration: none; }
table.jobs th a.sort.active { color: var(--fg); }

/* YAML editor pages: the example goes below the editor, not beside it */
.editor-cols { grid-template-columns: 1fr; }
.settings-form label.inline { max-width: 420px; }

/* Dashboard and chat */
.top5 { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.top5 .card { display: flex; gap: 14px; align-items: flex-start; margin: 0; }
.top5 .score { font-size: 1.3rem; min-width: 2.6em; padding: 4px 0; flex-shrink: 0; }
.top5-title { font-weight: 600; font-size: 1.02rem; }
.top5-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chat { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.chat-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 8px; }
.chat-head label { display: flex; flex-direction: column; gap: 2px; }
.chat-head select { max-width: 320px; }
.chat-log {
  min-height: 140px; max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column;
  gap: 8px; padding: 4px 2px 8px;
}
.msg { max-width: 92%; padding: 8px 12px; border-radius: 8px; line-height: 1.45; overflow-wrap: anywhere; }
.msg p { margin: 0 0 0.6em; }
.msg p:last-child { margin-bottom: 0; }
.msg pre {
  margin: 6px 0; padding: 8px; overflow-x: auto; font-size: 12.5px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
}
.msg.user { align-self: flex-end; background: var(--accent); color: var(--bg); }
.msg.user a { color: inherit; text-decoration: underline; }
.msg.assistant { align-self: flex-start; background: var(--chip); }
.msg.tool { align-self: flex-start; color: var(--muted); font-size: 0.82em; padding: 0 4px; }
.msg.tool::before { content: "⚙ "; }
.msg.error { align-self: stretch; max-width: 100%; border: 1px solid var(--bad); color: var(--bad); }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip-button { border-radius: 14px; padding: 4px 12px; background: var(--chip); }
.chat-form textarea { width: 100%; resize: vertical; }
.chat-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }

/* Application drafts */
.draft { margin: 18px 0; }
.draft .working { padding: 10px 12px; background: var(--chip); border-radius: 6px; }
.draft .notes { padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--chip); margin: 10px 0; }
.draft .actions { margin: 10px 0; }
.button.secondary { background: var(--chip); color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
details.preview { margin: 10px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
details.preview > summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
.markdown { padding: 4px 16px 12px; max-width: 46rem; }
.markdown h1 { font-size: 1.25rem; text-align: center; margin: 0.4em 0; }
.markdown h2 { font-size: 0.95rem; text-transform: uppercase; margin: 1.1em 0 0.3em; }
.markdown h3 { font-size: 0.95rem; margin: 0.8em 0 0.1em; }
.markdown p { margin: 0 0 0.7em; }
.markdown ul { margin: 0.2em 0 0.7em; padding-left: 1.3em; }
.draft-form { margin-top: 14px; }
.draft-form label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 0.9em; margin-bottom: 8px; max-width: 46rem; }
.draft-form textarea { width: 100%; font-weight: 400; }
.draft-form select { max-width: 22rem; font-weight: 400; }
.top5-draft { margin-left: auto; padding-left: 12px; white-space: nowrap; align-self: center; }

/* Account: the nav's user menu, and the login / password pages */
form.account { display: flex; gap: 8px; align-items: baseline; font-size: 0.9em; }
form.auth { display: flex; flex-direction: column; gap: 12px; max-width: 22em; margin-top: 16px; }
form.auth label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; color: var(--muted); }

/* Models and keys */
.settings-form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 0; }
form.inline input[type=password] { width: 16em; max-width: 100%; }
form.acting label { display: flex; gap: 6px; align-items: center; font-size: 0.85em; color: var(--muted); }
code.select-all { user-select: all; word-break: break-all; }
.qr svg { background: #fff; padding: 4px; border-radius: 4px; }

/* Preferences interview */
.interview { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; max-width: 46em; }
.interview .msg { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); }
.interview .msg.candidate { align-self: flex-end; background: var(--line); max-width: 85%; }
.interview .msg p:first-child { margin-top: 0; } .interview .msg p:last-child { margin-bottom: 0; }
form.interview-reply { max-width: 46em; } form.interview-reply textarea { width: 100%; }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.nudge { margin: 12px 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--line); border-radius: 4px; }
ol.calibrate { padding-left: 1.4em; } ol.calibrate li { margin: 0 0 14px; }
form.rate { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } form.rate input[name=note] { flex: 1; min-width: 12em; }
