:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #f0f1f4; --text: #16181d; --muted: #6b7280;
  --line: #e3e5ea; --accent: #e5484d; --accent-fg: #fff; --ok: #1f9d55; --warn: #c27c0e; --bad: #d1343a;
  --chip: #eef0f4; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --text: #e7e9ee; --muted: #9097a3;
    --line: #2a2f3a; --chip: #252a35; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --text: #e7e9ee; --muted: #9097a3;
  --line: #2a2f3a; --chip: #252a35; --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); min-height: 1.4em; }
h2 { font-size: 18px; margin: 0; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand.big { font-size: 24px; justify-content: center; margin-bottom: 8px; }
.logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff; font-size: 12px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav a { padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; color: var(--muted); }
nav a.active { background: var(--chip); color: var(--text); font-weight: 600; }
.badge { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }

input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.chk { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.searchbar { display: flex; gap: 8px; margin-bottom: 16px; }
.searchbar input { flex: 1; font-size: 16px; padding: 10px 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }

.movie { display: grid; grid-template-columns: minmax(240px, 420px) minmax(0, 1fr); gap: 18px; margin-bottom: 16px; }
.movie img.cover { width: 100%; border-radius: 8px; display: block; background: var(--panel2); aspect-ratio: 800/538; object-fit: cover; }
.movie h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.4; }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 4px 10px; font-size: 13px; }
.kv b { color: var(--muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--chip); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.chip.acc { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.samples { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.samples img { height: 72px; border-radius: 4px; cursor: zoom-in; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--panel2); margin-bottom: 12px; font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
table.cands { width: 100%; border-collapse: collapse; font-size: 13px; }
table.cands th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.cands td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cands tr.rej td { opacity: .5; }
table.cands td.t { word-break: break-all; min-width: 220px; }
table.cands td:last-child, table.cands td:nth-child(3) { white-space: nowrap; }
.score { font-variant-numeric: tabular-nums; font-weight: 600; }

.job { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 14px; margin-bottom: 10px; }
.job .title { font-weight: 600; }
.job .meta { font-size: 12px; color: var(--muted); }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; grid-column: 1 / -1; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.job.done .bar > i { background: var(--ok); }
.job.failed .bar > i { background: var(--bad); }
.joblog { grid-column: 1 / -1; font-size: 12px; color: var(--muted); max-height: 160px; overflow: auto; background: var(--panel2);
  border-radius: 6px; padding: 6px 8px; white-space: pre-wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile { cursor: pointer; border-radius: 10px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); }
.tile .ph { aspect-ratio: 2/3; background: var(--panel2) center/cover no-repeat; position: relative; }
.tile .ph .tag { position: absolute; left: 6px; top: 6px; }
.tile .cap { padding: 6px 8px; font-size: 12px; }
.tile .cap b { display: block; font-size: 13px; }
.tile .cap span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }

.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list-row:hover { background: var(--panel2); }
.list-row .name { flex: 1; min-width: 0; word-break: break-all; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.crumbs a { cursor: pointer; color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.stat-grid .card h4 { margin: 0 0 8px; font-size: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--panel); border-radius: 12px; width: min(980px, 100%); max-height: 92vh; overflow: auto; padding: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; }
.player-box .art { width: 100%; aspect-ratio: 16/9; max-height: 74vh; background: #000; border-radius: 8px; overflow: hidden; }
.ext-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ext-row a { text-decoration: none; cursor: pointer; }
.kvform { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; align-items: center; }
@media (max-width: 760px) { .kvform { grid-template-columns: 1fr; } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  nav { order: 3; width: 100%; flex: none; }
  main { padding: 12px; }
  .movie { grid-template-columns: minmax(0, 1fr); }
  .searchbar { flex-wrap: wrap; }
  .searchbar input { flex-basis: 100%; }
  table.cands .hide-m { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
}

.lib-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg a { padding: 5px 12px; border-radius: 999px; background: var(--chip); cursor: pointer; font-size: 13px; }
.seg a.on { background: var(--accent); color: var(--accent-fg); }
.seg a small { opacity: .75; margin-left: 4px; }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .ph .tag2 { position: absolute; right: 6px; top: 6px; }
.tile .ph .tag3 { position: absolute; left: 6px; bottom: 6px; }
a.chip.link { cursor: pointer; text-decoration: none; }
a.chip.link:hover { background: color-mix(in srgb, var(--accent) 20%, var(--chip)); }
