:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #17191c; --muted: #646a73; --line: #e2e5ea; --track: #e9ecf1;
  --accent: #2f5bea; --ok: #1f8a4c; --warn: #b26a00; --bad: #c43838;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --panel: #1a1d22; --text: #e9ebef; --muted: #9aa1ac; --line: #2a2e35; --track: #2a2e35;
    --accent: #7c9bff; --ok: #4cc27f; --warn: #e3a440; --bad: #ef6b6b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; padding: 8px 14px; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); padding: 6px 12px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.bar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
main { max-width: 960px; margin: 0 auto; padding: 8px 16px 48px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 28px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.count { font-size: 13px; font-weight: 400; color: var(--muted); }

.login { display: grid; place-items: center; min-height: 60vh; }
.login form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 24px; display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); }
.error { color: var(--bad); min-height: 1.5em; margin: 0; font-size: 13px; }

/* Running jobs: one card each, the progress is the main thing. */
.running { display: grid; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: grid; gap: 10px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.title { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.where { font-size: 13px; color: var(--muted); white-space: nowrap; text-align: right; }
.purpose { margin: -4px 0 0; color: var(--muted); font-size: 14px; }
.meter { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .6s ease; }
.meter.estimate > i { background: repeating-linear-gradient(45deg, var(--accent) 0 8px, color-mix(in srgb, var(--accent) 70%, transparent) 8px 16px); }
.meter.unknown > i { width: 30%; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.numbers { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.numbers b { font-weight: 600; }
.detail { font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.detail code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.empty { color: var(--muted); font-size: 14px; padding: 4px 2px; margin: 0; }

/* Waiting and finished jobs: one line each. */
.rows { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rows:empty { display: none; }
.row { display: grid; grid-template-columns: 10px 1fr auto; gap: 4px 12px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.done { background: var(--ok); } .dot.failed { background: var(--bad); } .dot.held, .dot.canceled { background: var(--warn); }
.row .name { font-weight: 500; overflow-wrap: anywhere; }
.row .side { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.row .sub { grid-column: 2 / -1; font-size: 13px; color: var(--muted); }
.row .sub.bad { color: var(--bad); }
.thumbs { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.thumb { width: 72px; height: 54px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); padding: 0; background: var(--bg); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.more { margin-top: 10px; }

@media (max-width: 560px) {
  .card-head { flex-direction: column; }
  .where { text-align: left; white-space: normal; }
  .row { grid-template-columns: 10px 1fr; }
  .row .side { grid-column: 2; text-align: left; }
}

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text);
  width: min(1100px, 96vw); max-height: 92vh; }
dialog::backdrop { background: rgb(0 0 0 / 60%); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); font-size: 13px; }
#viewer-body { display: grid; place-items: center; padding: 10px; }
#viewer-body img, #viewer-body video { max-width: 100%; max-height: 80vh; display: block; }
#viewer-body a { margin-top: 8px; font-size: 13px; color: var(--accent); }
