:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #646a73;
  --line: #e3e5e8;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok: #1f9d55;
  --warn: #b7791f;
  --bad: #d64545;
  --soft: #eef3fe;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1f2226;
    --text: #e8eaed;
    --muted: #a0a6ad;
    --line: #34383d;
    --accent: #5b8cff;
    --soft: #23304a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  overflow-x: hidden;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 16px 48px; }
header { padding: 12px 2px 4px; }
header h1 { font-size: 22px; margin: 0 0 4px; }
header p { margin: 0; color: var(--muted); font-size: 14px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.linkbtn { background: none; border: 0; color: var(--accent); font-size: 14px; padding: 8px 4px; min-height: 40px; cursor: pointer; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
}
.card h2 { font-size: 17px; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* file pickers */
.picker {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--line); border-radius: 12px; min-height: 120px; padding: 12px;
  text-align: center; cursor: pointer; position: relative; background: var(--bg);
}
.picker:active { background: var(--soft); }
.picker input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.picker .big { font-size: 17px; font-weight: 600; color: var(--accent); }
.picker .small { font-size: 13px; color: var(--muted); }
.preview { margin-top: 10px; display: none; }
.preview img, .preview video { display: block; max-width: 100%; max-height: 50vh; margin: 0 auto; border-radius: 10px; background: #000; }
.fileinfo { font-size: 13px; color: var(--muted); margin-top: 6px; word-break: break-all; text-align: center; }

/* choices */
.field { margin: 12px 0; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 15px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { flex: 1 1 calc(33% - 8px); min-width: 88px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); font-size: 15px; cursor: pointer; line-height: 1.25;
}
.seg small { font-size: 12px; font-weight: 400; color: var(--muted); }
.seg input:checked + span { border-color: var(--accent); background: var(--soft); color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg input:disabled + span { opacity: .45; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
input[type=text], input[type=number], textarea {
  width: 100%; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font-family: inherit;
}
input[type=range] { width: 100%; height: 32px; accent-color: var(--accent); }
details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--accent); }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸"; margin-right: 6px; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  min-height: 52px; border-radius: 12px; border: 0; font-size: 17px; font-weight: 600;
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none;
  padding: 0 16px; font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.small { min-height: 44px; font-size: 15px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

.msg { padding: 10px 12px; border-radius: 10px; font-size: 15px; margin: 10px 0 0; display: none; }
.msg.error { display: block; background: rgba(214, 69, 69, .1); color: var(--bad); }
.msg.info { display: block; background: var(--soft); color: var(--text); }

.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }

/* jobs */
.job { border-top: 1px solid var(--line); padding: 14px 0; }
.job:first-of-type { border-top: 0; padding-top: 4px; }
.job .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.job .title { font-weight: 600; font-size: 15px; word-break: break-all; }
.badge { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--soft); color: var(--accent); white-space: nowrap; }
.badge.done { background: rgba(31, 157, 85, .12); color: var(--ok); }
.badge.failed, .badge.missing { background: rgba(214, 69, 69, .12); color: var(--bad); }
.badge.cancelled { background: var(--line); color: var(--muted); }
.stats { font-size: 14px; color: var(--muted); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.stats b { color: var(--text); font-weight: 600; }
.job video { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: 10px; margin: 10px 0; }
.score { font-size: 14px; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.score .num { font-size: 20px; font-weight: 700; }
.warn { color: var(--warn); font-size: 14px; margin: 6px 0; }
.err { color: var(--bad); font-size: 15px; margin: 6px 0; }
.segtable { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.segtable td, .segtable th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.empty { color: var(--muted); font-size: 14px; }
ul.tips { padding-left: 20px; margin: 6px 0; font-size: 14px; }
ul.tips li { margin: 4px 0; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* login */
.login { max-width: 400px; margin: 10vh auto 0; }
.login .field input { min-height: 48px; }

@media (max-width: 899px) {
  .cols { display: flex; flex-direction: column; }
  body.has-jobs .cols aside { order: -1; }
}
@media (min-width: 900px) {
  .wrap { max-width: 1080px; }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
}
#lengths label:first-child { flex-basis: 100%; }
