:root {
  --bg: #f4f5f7; --card: #fff; --fg: #1b1d22; --muted: #6b7080; --line: #e2e4ea;
  --accent: #e5a00d; --accent-fg: #1b1d22; --ok: #2e9d57; --err: #d14343; --warn: #c58a00;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181d; --card: #20232a; --fg: #eceef2; --muted: #9aa0ad; --line: #2f333c; }
}
* { box-sizing: border-box; }
body {
  margin: 0 auto; max-width: 760px; padding: 0 16px 48px; background: var(--bg); color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
button {
  font: inherit; border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg); font-weight: 600;
}
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
button.link { background: none; color: var(--muted); padding: 4px; font-weight: 400; text-decoration: underline; }
button.icon { background: none; color: var(--fg); font-size: 22px; padding: 4px 8px; }
button:disabled { opacity: .5; cursor: default; }
input, select {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg);
}
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
#sticky { position: sticky; top: 0; background: var(--bg); padding: 6px 0 8px; z-index: 2; margin-bottom: 8px; }
#search { display: flex; gap: 8px; }
#tabs { display: flex; gap: 4px; margin-bottom: 8px; }
#tabs button { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; padding: 6px 12px; border-radius: 999px; }
#tabs button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
#dest { display: grid; grid-template-columns: auto 1fr 1.2fr 1fr; gap: 6px; align-items: center; margin-top: 8px; }
#dest select, #dest input { padding: 6px 8px; font-size: 13px; min-width: 0; }
.dest-label { font-size: 13px; color: var(--muted); }
#d-preview { margin-top: 3px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  #dest { grid-template-columns: 1fr 1fr; }
  .dest-label { display: none; }
  #d-subdir { grid-column: 1 / -1; grid-row: 2; }
}
.coll {
  display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start;
  background: var(--card); border: 1px solid var(--accent); border-radius: 12px; padding: 12px; margin-bottom: 10px;
}
.coll img, .coll .ph { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: var(--line); }
.coll .t { white-space: normal; font-size: 17px; }
.coll-acts { grid-column: 1 / -1; display: grid; gap: 8px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.chk input { width: auto; }
.row-item { display: grid; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.row-item .t, .row-item .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch { margin-bottom: 8px; }
.batch-head { cursor: pointer; margin-bottom: 0; }
.batch-items { margin: 6px 0 0 18px; }
.chev { color: var(--muted); font-size: 18px; padding: 0 6px; }
#settings { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 12px; margin-bottom: 8px; }
#settings[hidden] { display: none; }
#settings label { display: grid; gap: 5px; font-weight: 600; font-size: 14px; }
#settings small { font-weight: 400; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; word-break: break-all; }
#set-msg { color: var(--ok); font-size: 14px; }

.card {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px;
}
.card img, .ph { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--line); }
.meta { min-width: 0; }
.t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e { display: inline-block; font-size: 10px; border: 1px solid var(--muted); color: var(--muted); border-radius: 3px; padding: 0 3px; margin-left: 4px; vertical-align: 2px; }
.kind { display: inline-block; font-size: 11px; border-radius: 4px; padding: 0 5px; margin-left: 2px; background: var(--line); color: var(--fg); }
.kind.compil { background: var(--warn); color: #fff; }
.acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.acts button { padding: 7px 12px; font-size: 14px; }
.cands { grid-column: 1 / -1; display: grid; gap: 6px; }
.cand {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--line);
}
.cand.best { border-color: var(--accent); }
.cand a { color: inherit; }
.why { font-size: 12px; color: var(--muted); }
.score { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }

#source { background: var(--card); border: 1px dashed var(--accent); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
#source[hidden] { display: none; }
#jobs-wrap { margin-top: 22px; }
#jobs-wrap[hidden] { display: none; }
#jobs { margin-top: 8px; }
.job .s.status-done { color: var(--ok); }
.job .s.status-error { color: var(--err); white-space: normal; }
.job .s.status-skipped { color: var(--warn); }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.msg { color: var(--muted); text-align: center; padding: 20px; }
.err { color: var(--err); }

body.login { display: grid; place-items: center; min-height: 100vh; }
body.login form { display: grid; gap: 12px; width: min(320px, 100%); }
