/* Prompt Pad Queue — single stylesheet, no build step. Light/dark via prefers-color-scheme. */

:root {
	--bg: #f5f6f8;
	--panel: #ffffff;
	--panel-2: #f0f2f5;
	--text: #1c2127;
	--muted: #5d6874;
	--dim: #9aa3ad;
	--border: #dfe3e8;
	--border-strong: #c9cfd6;
	--accent: #2563d6;
	--accent-hover: #1d50b0;
	--accent-text: #ffffff;
	--bad: #c0392b;
	--bad-bg: #fdecea;
	--warn: #9a5b00;
	--warn-bg: #fff4dc;
	--ok: #1f7a3a;
	--ok-bg: #e5f5e9;
	--info-bg: #e8f0fd;
	--code-bg: #eef1f4;
	--log-bg: #fbfbfc;
	--shadow: 0 1px 2px rgba(16, 24, 40, .05);
	--radius: 8px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

	/* status badges: background / text */
	--st-queued: #e6ecf5;    --st-queued-t: #3b4f6b;
	--st-held: #fff1d1;      --st-held-t: #8a5600;
	--st-claimed: #ebe7fb;   --st-claimed-t: #5137a8;
	--st-running: #dceafe;   --st-running-t: #1d4fb0;
	--st-cancelreq: #ffe6d5; --st-cancelreq-t: #a4440c;
	--st-done: #dff3e5;      --st-done-t: #1c6b34;
	--st-failed: #fbe1de;    --st-failed-t: #a42a1d;
	--st-cancelled: #eceef1; --st-cancelled-t: #5d6874;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #111418;
		--panel: #181c21;
		--panel-2: #1f242a;
		--text: #e3e7ec;
		--muted: #9aa5b1;
		--dim: #66707b;
		--border: #2a3037;
		--border-strong: #39414a;
		--accent: #5b93f5;
		--accent-hover: #7aa8f7;
		--accent-text: #0d1117;
		--bad: #f07468;
		--bad-bg: #3a1d1a;
		--warn: #e8b04f;
		--warn-bg: #352812;
		--ok: #5fcb7d;
		--ok-bg: #16301e;
		--info-bg: #172338;
		--code-bg: #22282f;
		--log-bg: #14181c;
		--shadow: none;

		--st-queued: #253041;    --st-queued-t: #a9bcd8;
		--st-held: #3a2d12;      --st-held-t: #f0c069;
		--st-claimed: #2c2550;   --st-claimed-t: #b9a8f5;
		--st-running: #172c4f;   --st-running-t: #8fb6f8;
		--st-cancelreq: #43260f; --st-cancelreq-t: #f4a86b;
		--st-done: #173322;      --st-done-t: #78d494;
		--st-failed: #44201c;    --st-failed-t: #f39186;
		--st-cancelled: #262b31; --st-cancelled-t: #9aa5b1;
	}
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.5 var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .path { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }

h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 18px; padding-bottom: 48px; }

/* --- top bar --- */
.topbar { background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar-in { display: flex; align-items: center; gap: 20px; min-height: 50px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.brand-lg { font-size: 22px; text-align: center; margin-bottom: 18px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.nav a.on { color: var(--text); background: var(--panel-2); font-weight: 600; }
.logout { display: flex; align-items: center; gap: 8px; margin: 0; }

/* --- page --- */
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.page-title { font-size: 21px; font-weight: 650; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-break { overflow-wrap: anywhere; }
.page-head > div:first-child { min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.status-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section { margin-bottom: 24px; }
.count { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 4px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.main-col { min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1000px) {
	.layout { grid-template-columns: minmax(0, 1fr); }
}

.card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px 16px;
	box-shadow: var(--shadow);
}
.card + .card, .card + .section, .section + .card { margin-top: 16px; }
.side-col .card + .card { margin-top: 0; }
.hint { margin-bottom: 20px; background: var(--info-bg); }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.clip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.path { color: var(--muted); word-break: break-all; }

/* --- flash --- */
.flash { padding: 9px 12px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash-warn, .flash-info { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.stalled form.inline { margin-left: 6px; }
.stalled code { white-space: nowrap; }
/* Offered by app.js instead of reloading while a form is being filled in. */
.live-note { position: fixed; right: 16px; bottom: 16px; z-index: 20; box-shadow: var(--shadow); }

/* --- tables --- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
.table tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .title-cell { min-width: 220px; overflow-wrap: anywhere; }
.table .title-cell .path { font-size: 11.5px; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions-h { text-align: right; }
.row-held td { background: color-mix(in srgb, var(--st-held) 35%, transparent); }
.row-revoked td { opacity: .6; }

/* --- badges & tags --- */
.badge {
	display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
	white-space: nowrap; line-height: 1.6; background: var(--st-cancelled); color: var(--st-cancelled-t);
}
.st-queued { background: var(--st-queued); color: var(--st-queued-t); }
.st-held { background: var(--st-held); color: var(--st-held-t); }
.st-claimed { background: var(--st-claimed); color: var(--st-claimed-t); }
.st-running { background: var(--st-running); color: var(--st-running-t); }
.st-running::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: 1px; animation: pulse 1.4s ease-in-out infinite; }
.st-cancel_requested { background: var(--st-cancelreq); color: var(--st-cancelreq-t); }
.st-done, .st-on { background: var(--st-done); color: var(--st-done-t); }
.st-failed { background: var(--st-failed); color: var(--st-failed-t); }
.st-cancelled { background: var(--st-cancelled); color: var(--st-cancelled-t); }
.st-off { background: var(--st-held); color: var(--st-held-t); }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .st-running::before { animation: none; } }

.tag { display: inline-block; font-size: 11.5px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); line-height: 1.6; }
.tag-root { font-style: italic; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot-off { background: var(--dim); }

.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.agents > .card { margin: 0; }
.agent { padding: 10px 14px; }

/* --- buttons --- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 4px;
	font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2;
	padding: 7px 12px; border-radius: 6px; cursor: pointer;
	border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
	white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-text { color: var(--bad); }
.btn-sm { padding: 3px 8px; font-size: 12.5px; }
.btn-icon { min-width: 28px; }
form.inline { display: inline; margin: 0; }
.actions form.inline + form.inline, .actions form.inline + a, .actions a + form.inline { margin-left: 2px; }

/* --- forms --- */
.form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; gap: 7px; font-weight: 400; }
.form label .muted { font-weight: 400; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-wide { max-width: 900px; }
.form-inline { flex-direction: row; flex-wrap: wrap; }
.form-inline input[type="text"] { flex: 1; min-width: 200px; }
.form-actions { display: flex; gap: 8px; }
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], select, textarea {
	font: inherit; font-size: 14px; color: var(--text); background: var(--panel);
	border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 9px; width: 100%;
}
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.45; resize: vertical; min-height: 90px; }
input.prio { width: 72px; padding: 3px 6px; font-size: 13px; }
.prio-form { white-space: nowrap; }
.js .js-hide { display: none; }

/* --- login --- */
.login { max-width: 360px; margin: 10vh auto 0; }

/* --- task page --- */
.text-block {
	margin: 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
	white-space: pre-wrap; word-break: break-word; max-height: 480px; overflow: auto; font-size: 13px; line-height: 1.5;
}
.text-block-bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); color: var(--bad); }
.resume { margin-bottom: 18px; }
.resume-head { margin-bottom: 8px; }
.cmd { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 6px 9px; display: block; }
.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 13px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; min-width: 0; word-break: break-word; }
.files { margin: 0; padding-left: 18px; font-size: 13px; }
.files li { margin: 2px 0; }
.token-card { border-color: var(--accent); margin-bottom: 16px; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.plist li { font-size: 13px; }
.plist .path { font-size: 11.5px; }
.plist li.missing { opacity: .6; }

/* --- live log --- */
.log-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.log-head h2 { margin-bottom: 8px; }
.log {
	background: var(--log-bg); border: 1px solid var(--border); border-radius: var(--radius);
	font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
	max-height: 70vh; min-height: 120px; overflow: auto; padding: 6px 0;
}
.log-empty { padding: 8px 12px; font-family: var(--font); }
.ll { display: grid; grid-template-columns: 64px 84px minmax(0, 1fr); gap: 8px; padding: 1px 12px; }
.ll:hover { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.ll-ts { color: var(--dim); }
.ll-type { color: var(--dim); font-size: 11.5px; text-transform: lowercase; }
.ll-text { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.ll.long .ll-text { max-height: 9em; overflow: hidden; cursor: zoom-in; mask-image: linear-gradient(#000 70%, transparent); -webkit-mask-image: linear-gradient(#000 70%, transparent); }
.ll.long.open .ll-text { max-height: none; cursor: zoom-out; mask-image: none; -webkit-mask-image: none; }
.t-runner .ll-text { color: var(--accent); font-style: italic; }
.t-system .ll-text { color: var(--muted); }
.t-assistant .ll-text { color: var(--text); font-family: var(--font); font-size: 13.5px; }
.t-tool .ll-text { color: var(--st-claimed-t); }
.t-tool_result .ll-text { color: var(--muted); font-size: 12px; }
.t-result { background: var(--ok-bg); }
.t-result .ll-text { color: var(--ok); font-weight: 600; }
.t-stderr .ll-text { color: var(--bad); }
.ll-sep { padding: 6px 12px 2px; color: var(--muted); font-family: var(--font); font-size: 12px; font-weight: 600; border-top: 1px dashed var(--border); margin-top: 4px; }
.ll-sep:first-child { border-top: 0; margin-top: 0; }

/* --- phone --- */
@media (max-width: 640px) {
	body { font-size: 14.5px; }
	.topbar-in { gap: 10px; padding-top: 6px; padding-bottom: 6px; }
	.nav { order: 3; flex-basis: 100%; }
	.logout { margin-left: auto; }
	.page-title { font-size: 18px; }
	.form .row2 { grid-template-columns: 1fr; }
	.ll { grid-template-columns: 56px minmax(0, 1fr); }
	.ll-type { display: none; }
	.table .title-cell { min-width: 180px; }
}
