:root {
  --bg: #f6f5f2; --panel: #ffffff; --text: #1d1d1b; --muted: #77756f; --line: #e4e2dc;
  --accent: #2f5bea; --accent-ink: #fff; --ok: #1f9d55; --warn: #c27c0e; --bad: #d23c3c;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151515; --panel: #1f1f1f; --text: #ecebe8; --muted: #9a9892; --line: #333;
          --accent: #6d8dff; --accent-ink: #0b0b0b; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.top { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.top .spacer { flex: 1; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
.accounts { display: flex; gap: 8px; flex-wrap: wrap; }
.acc { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line);
       border-radius: 99px; font-size: 12px; }
.acc i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.acc.cooldown i { background: var(--warn); }
.acc.needs_login i, .acc.no_access i { background: var(--bad); }
.acc.off i { background: var(--muted); }
.acc small { color: var(--muted); }
.acc button { font-size: 11px; padding: 0 6px; border: 1px solid var(--line); background: none; border-radius: 6px; cursor: pointer; }

.layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; padding: 18px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; padding: 12px 16px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
         position: sticky; top: 62px; max-height: calc(100vh - 80px); overflow: auto; }
@media (max-width: 860px) { .panel { position: static; max-height: none; } }
.panel label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13px; }
.panel label.check { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.panel input[type=file], .panel select, .panel textarea, .login-card input {
  width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-weight: 400; }
.panel textarea { resize: vertical; }
.row { display: flex; gap: 8px; }
.row label { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0; }
.warn { color: var(--warn); font-size: 12px; }
.block { border-left: 3px solid var(--line); padding-left: 10px; margin: 8px 0; }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 9px; }
.tab { flex: 1; border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs.small .tab { flex: none; }

.primary { width: 100%; margin-top: 14px; padding: 10px; border: 0; border-radius: 8px; background: var(--accent);
           color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: .5; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { position: relative; }
.chip img { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.chip button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0;
               background: var(--bad); color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; }

.results-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.results-head select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.empty { grid-column: 1 / -1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.kept { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.card.rejected { opacity: .55; }
.media { display: grid; grid-template-columns: 1fr; gap: 2px; background: #000; }
.media:has(> :nth-child(2)) { grid-template-columns: 1fr 1fr; }
.media img, .media video { width: 100%; display: block; max-height: 420px; object-fit: contain; cursor: zoom-in; background: #000; }
.media video { cursor: default; }
.placeholder { aspect-ratio: 9 / 12; display: flex; flex-direction: column; align-items: center; justify-content: center;
               background: var(--bg); color: var(--muted); font-weight: 600; }
.placeholder small { font-weight: 400; margin-top: 4px; }
.placeholder.running { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.line { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--bg); }
.badge.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.failed { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.badge.running { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.meta { font-size: 12px; color: var(--muted); }
.prompt { margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.err { margin: 2px 0; font-size: 12px; color: var(--bad); word-break: break-word; }
.actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.actions button, .actions .btn { font-size: 12px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px;
       background: var(--bg); cursor: pointer; text-decoration: none; color: var(--text); }
.actions .on { border-color: var(--ok); color: var(--ok); }
.actions .on.bad { border-color: var(--bad); color: var(--bad); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 20; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }

.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 360px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card label { display: block; margin-top: 12px; font-weight: 600; }
.error { color: var(--bad); }
