/* CreoAgent: один файл стилей, без внешних ресурсов */
:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --card: #fff; --soft: #eef0f3; --line: #dce0e6; --fg: #1c2026; --muted: #5b6471;
  --accent: #2456d3; --accent-fg: #fff; --focus: #2456d3;
  --ok: #19773a; --warn: #955400; --danger: #c0281e; --violet: #6a3dc4; --info: #2456d3;
  --r: 10px; --shadow: 0 1px 2px rgb(16 24 40 / 6%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111316; --card: #1a1d22; --soft: #23272d; --line: #30363e; --fg: #e8eaed; --muted: #9ba4af;
    --accent: #7ea6ff; --accent-fg: #0b1220; --focus: #9bbaff;
    --ok: #5fcf89; --warn: #f0b45a; --danger: #ff7d73; --violet: #b99dff; --info: #7ea6ff; --shadow: none;
  }
}
*, ::before, ::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); overflow-wrap: break-word;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .5rem; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; line-height: 1.3; margin: 0 0 .75rem; }
p { margin: .5rem 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.vh, .drop.on input[type="file"] {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; top: 8px; z-index: 10; padding: 8px 12px; background: var(--card); border-radius: 8px; }
.skip:focus { left: 8px; }

/* Шапка */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; max-width: 980px; margin: 0 auto; padding: 10px 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--fg); text-decoration: none; }
.brand::before { content: ""; width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--violet)); }
.nav, .me, .tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.nav a, .tabs a { padding: 4px 0; color: var(--fg); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav a:hover, .tabs a:hover { border-bottom-color: var(--line); }
.nav a[aria-current], .tabs a[aria-current] { border-bottom-color: var(--accent); font-weight: 600; }
.me { margin-left: auto; font-size: .95rem; }
.me a { max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.me a[aria-current] { color: var(--fg); }
main { max-width: 980px; margin: 0 auto; padding: 20px 16px 56px; }
.tabs { margin: -4px 0 18px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }

/* Блоки */
.card { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card + .card, .table-wrap + .card { margin-top: 16px; }
.sec { margin-top: 24px; }
.narrow { max-width: 440px; margin: 24px auto; }
.mid { max-width: 760px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.head h1 { margin: 0; }
.head p { margin: 2px 0 0; }
.head > div { min-width: 0; }
.actions, .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.inline { display: inline; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.back { display: inline-block; margin-bottom: 8px; font-size: .9rem; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--r); }
.empty p { margin: 0 0 12px; }
.alert, .ok, .notice, .secret {
  margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--c); border-radius: 8px;
  background: color-mix(in srgb, var(--c) 10%, var(--card));
}
.alert { --c: var(--danger); }
.ok { --c: var(--ok); }
.notice { --c: var(--warn); }
.notice.info { --c: var(--info); }
.secret { --c: var(--accent); }
:is(.alert, .ok, .notice, .secret) > :first-child { margin-top: 0; }
:is(.alert, .ok, .notice, .secret) > :last-child { margin-bottom: 0; }
.big { display: inline-block; padding: 2px 8px; font-size: 1.35rem; letter-spacing: .05em; user-select: all; background: var(--card); border-radius: 6px; }
pre.error-text { max-height: 18em; overflow: auto; margin: 6px 0 0; padding: 8px 10px; font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); border-radius: 6px; }
.err { color: var(--danger); }
summary { cursor: pointer; color: var(--muted); font-size: .875rem; }

/* Формы */
.stack, .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stack label, .field-title { font-weight: 600; }
.stack > label:not(:first-of-type), .field + .field { margin-top: 10px; }
.hint { color: var(--muted); font-size: .875rem; font-weight: 400; }
input, select, textarea, button, .btn { font: inherit; color: inherit; }
input:not([type]), input[type="password"], select, textarea {
  width: 100%; padding: 9px 11px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
:is(input, select, textarea):hover { border-color: var(--muted); }
select { width: auto; max-width: 100%; }
textarea { min-height: 6em; resize: vertical; line-height: 1.45; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:disabled { opacity: .6; cursor: default; }
.primary { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.danger:hover { border-color: var(--danger); }
.small:is(button, .btn) { min-height: 32px; padding: 4px 11px; }
.linklike { min-height: 0; padding: 0; color: var(--accent); background: none; border: 0; text-decoration: underline; text-underline-offset: 2px; }
.stack > button, .stack > .row { align-self: flex-start; margin-top: 8px; }

/* Файлы */
.drop { position: relative; background: var(--soft); border: 2px dashed var(--line); border-radius: var(--r); transition: border-color .15s, background-color .15s; }
.drop:hover, .drag .drop { border-color: var(--accent); }
.drop.on:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.drag .drop { background: color-mix(in srgb, var(--accent) 8%, var(--soft)); }
.drop input[type="file"] { display: block; max-width: calc(100% - 28px); margin: 12px 14px 0; }
.drop-ui { display: block; padding: 18px 14px; text-align: center; font-weight: 400; cursor: pointer; }
.drop-ui strong { color: var(--accent); }
.drop-ui .hint { display: block; margin-top: 2px; }
.dnd { display: none; }
@media (hover: hover) { .on .dnd { display: inline; } }
.picked { margin: 0; padding: 0 10px 10px; list-style: none; font-size: .9rem; }
.picked:empty { display: none; }
.picked li { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.picked li + li { margin-top: 4px; }
.picked .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.picked .x { min-height: 30px; padding: 0 10px; font-size: 1.2rem; line-height: 1; color: var(--muted); background: none; border-color: transparent; }
.picked .x:hover { color: var(--danger); }
.chips { display: none; flex-wrap: wrap; align-items: center; gap: 6px; }
.js .chips { display: flex; }
.chip { min-height: 32px; padding: 4px 12px; font-size: .875rem; text-align: left; white-space: normal; background: var(--soft); border-radius: 999px; }
.chip:hover { border-color: var(--accent); }
.progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; background: var(--soft); border-radius: 8px; }
.progress [data-pct] { flex: 1; }
progress { flex: 1 1 100%; width: 100%; height: 10px; accent-color: var(--accent); }

/* Статусы */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; vertical-align: middle;
  font-size: .8rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border-radius: 999px;
  color: var(--muted); background: color-mix(in srgb, currentColor 13%, transparent);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.s-queued::before { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.pill.s-running { color: var(--info); }
.pill.s-running::before { animation: pulse 1.4s ease-in-out infinite; }
.pill.s-done { color: var(--ok); }
.pill.s-needs_reply { color: var(--warn); }
.pill.s-error { color: var(--danger); }
.pill.s-waiting_limit { color: var(--violet); }
@keyframes pulse { 50% { opacity: .25; } }

/* Список задач */
.jobs { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.jobs li {
  position: relative; display: flex; align-items: center; gap: 6px 16px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.jobs li:hover { border-color: var(--muted); }
.jobs li:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.job-link { flex: 1; min-width: 0; color: var(--fg); text-decoration: none; }
.job-link:focus-visible { outline: 0; }
.job-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.job-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.job-task { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.job-meta { display: flex; flex-direction: column; flex-shrink: 0; align-items: flex-end; gap: 4px; color: var(--muted); font-size: .85rem; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; }
.seg a { padding: 5px 12px; color: var(--fg); font-size: .9rem; text-decoration: none; border-radius: 6px; }
.seg a[aria-current] { font-weight: 600; background: var(--card); box-shadow: 0 0 0 1px var(--line); }

/* Переписка */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.msg {
  min-width: 0; padding: 12px 14px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--c, var(--line)) 45%, var(--line));
}
.msg.user { margin-left: 12%; background: var(--soft); box-shadow: none; }
.msg.agent { margin-right: 12%; }
.msg.s-done { --c: var(--ok); }
.msg.s-error { --c: var(--danger); }
.msg.s-needs_reply { --c: var(--warn); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-bottom: 6px; color: var(--muted); font-size: .8rem; }
.who { color: var(--fg); font-weight: 600; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .875rem; }
.files li { max-width: 100%; padding: 3px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.files a { overflow-wrap: anywhere; }
.files li > .muted { white-space: nowrap; }
.files img { width: 28px; height: 28px; margin: -2px 6px 0 -6px; vertical-align: middle; object-fit: contain; background: var(--soft); border-radius: 4px; }
.result { margin: 12px 0 0; }
.result :is(video, img) { display: block; width: auto; height: auto; max-width: min(100%, 360px); max-height: 70vh; background: #000; border-radius: 8px; }
.result figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; font-size: .9rem; overflow-wrap: anywhere; }
.reply .hint { margin: 0; }

/* Таблицы и факты */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 9px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); background: var(--soft); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--muted); }
.table .num { white-space: nowrap; }
.table .wide { overflow-wrap: anywhere; }
/* «Расход»: 11 столбцов */
.compact :is(th, td) { padding-left: 6px; padding-right: 6px; }
.compact .first { white-space: nowrap; }
.table td form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.table select { padding: 5px 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.facts { display: grid; grid-template-columns: minmax(9em, max-content) 1fr; gap: 12px 20px; margin: 0; }
.facts dt { font-weight: 600; }
.facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
meter { width: 9em; height: 10px; margin-right: 6px; vertical-align: middle; }

@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  main { padding-top: 16px; }
  .bar { gap: 4px 16px; padding-bottom: 6px; }
  .nav { order: 3; width: 100%; }
  .msg.user, .msg.agent { margin-left: 0; margin-right: 0; }
  .jobs li { flex-direction: column; align-items: stretch; }
  .job-meta { flex-direction: row; justify-content: space-between; align-items: center; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 12px; }
  .narrow { margin: 8px auto; }
  .table-wrap { overflow: visible; background: none; border: 0; }
  .table, .table tbody { display: block; }
  .table thead { display: none; }
  .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin-bottom: 8px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
  .table td { padding: 2px 0; border: 0 !important; }
  .table td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .8rem; }
  .table td.wide { flex-basis: 100%; }
  .table td.first { order: -1; margin-bottom: 2px; white-space: normal; }
  .table td form, .row-actions { margin: 4px 0; }
}
@media (prefers-reduced-motion: reduce) { *, ::before { transition: none !important; animation: none !important; } }
