:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --bg2: var(--tg-theme-secondary-bg-color, #181b21);
  --card: var(--tg-theme-section-bg-color, #1c2027);
  --text: var(--tg-theme-text-color, #eef0f3);
  --hint: var(--tg-theme-hint-color, #8a919c);
  --accent: var(--tg-theme-button-color, #3b82f6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --r: 14px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { padding: 12px 14px calc(84px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 2px 12px; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--hint);
  margin: 22px 4px 8px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.muted { color: var(--hint); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

input[type=url] { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 15px; outline: none; }
input[type=url]:focus { border-color: var(--accent); }
.btn { border: 0; border-radius: 10px; padding: 11px 14px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: var(--accent-text); cursor: pointer; white-space: nowrap; }
.btn.ghost { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.btn.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.btn:disabled { opacity: .5; }
.or { text-align: center; color: var(--hint); font-size: 13px; margin: 10px 0; }
.upload { display: block; text-align: center; border: 1px dashed var(--line); border-radius: 10px;
  padding: 12px; color: var(--accent); font-weight: 600; cursor: pointer; }
.upload input { display: none; }

.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }

.job { display: block; color: var(--text); }
.job .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.chip.queued { background: var(--line); color: var(--hint); }
.chip.running { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.chip.done { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.chip.failed { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }

.stages { list-style: none; padding: 0; margin: 0; }
.stages li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line); align-items: start; }
.stages li:last-child { border-bottom: 0; }
.dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px;
  background: var(--line); color: var(--hint); margin-top: 1px; }
.done .dot { background: var(--good); color: #fff; }
.run .dot { background: var(--accent); color: #fff; }
.run .dot::after { content: ""; width: 10px; height: 10px; border: 2px solid #fff; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; }
.skip .dot { opacity: .5; }
.fail .dot { background: var(--bad); color: #fff; }
.cand { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cand:last-child { border-bottom: 0; }
.cand .ttl { font-weight: 600; font-size: 14px; }
.score.small { min-width: 38px; height: 38px; font-size: 14px; border-radius: 10px; background: var(--line); color: var(--text); }
.score.small.hi { background: var(--good); color: #fff; }
.score.small.mid { background: var(--warn); color: #fff; }
.stages .name { font-weight: 600; }
.wait .name, .skip .name { color: var(--hint); font-weight: 500; }
.stages .time { font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }
@keyframes spin { to { transform: rotate(360deg); } }

.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--text);
  border-left: 3px solid var(--bad); padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg2); border-radius: 10px; padding: 9px; text-align: center; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--hint); }

.filters { display: flex; gap: 6px; margin: 4px 0 12px; overflow-x: auto; }
.filters button { border: 0; background: var(--card); color: var(--hint); border-radius: 99px;
  padding: 7px 13px; font-size: 14px; font-weight: 600; }
.filters button.on { background: var(--accent); color: var(--accent-text); }

.clip { padding: 0; overflow: hidden; }
.clip video { width: 100%; aspect-ratio: 9/16; max-height: 62vh; background: #000; display: block; object-fit: contain; }
.clip .body { padding: 12px 14px 14px; }
.clip .head { display: flex; gap: 10px; align-items: start; }
.score { min-width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 18px; color: #fff; background: var(--accent); font-variant-numeric: tabular-nums; }
.score.hi { background: var(--good); }
.score.mid { background: var(--warn); }
.clip .ttl { font-weight: 700; font-size: 16px; }
.reason { margin: 8px 0 0; font-size: 14px; }
.critic { margin: 6px 0 0; font-size: 13px; color: var(--hint); font-style: italic; }
.crit { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; margin: 10px 0; }
.crit div { font-size: 11px; color: var(--hint); }
.crit .bar { height: 4px; margin-top: 3px; }
details { margin-top: 8px; font-size: 14px; }
summary { color: var(--accent); cursor: pointer; font-weight: 600; font-size: 13px; }
.hook { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hook:last-child { border: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.actions .btn { flex: 1; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reasons button { border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 99px; padding: 6px 11px; font-size: 13px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.badge.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge.no { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.empty { text-align: center; color: var(--hint); padding: 40px 20px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px;
  color: var(--hint); font-size: 11px; font-weight: 600; }
.tabs a.on { color: var(--accent); }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 9; max-width: 90vw; }
.toast.show { opacity: 1; }
.back { display: inline-block; margin: 4px 0 6px; font-weight: 600; }

.crowd { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--good); }
