:root {
  --bg: #f6f6f4; --card: #fff; --line: #e4e3df; --text: #1c1c1a; --dim: #77756f;
  --accent: #3d5afe; --accent-ink: #fff; --bad: #d33a2c; --wave: #c9c7c1; --soft: #efeeea;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314; --card: #1c1c1e; --line: #2c2c30; --text: #ececea; --dim: #8e8d88;
    --accent: #7c8cff; --accent-ink: #0d0d10; --bad: #ff6b5e; --wave: #4a4a50; --soft: #26262a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

header {
  display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px;
  max-width: 880px; margin: 0 auto;
}
.brand { font-weight: 650; font-size: 17px; letter-spacing: .02em; }
.sp { flex: 1; }
.link { color: var(--dim); }
.link:hover { color: var(--text); }
main { max-width: 880px; margin: 0 auto; padding: 8px 20px 80px; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; color: var(--dim); display: flex; align-items: center; gap: 4px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { color: var(--text); }
.menu div {
  position: absolute; right: 0; top: 30px; z-index: 5; min-width: 120px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .12);
}
.menu div button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 6px; }
.menu div button:hover { background: var(--soft); }

.btn {
  height: 36px; padding: 0 16px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-weight: 550; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.quiet { background: var(--soft); color: var(--text); font-weight: 400; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], select {
  height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--dim); flex: none; }
.icon:hover { background: var(--soft); color: var(--text); }
.icon.sure { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

/* drop zone */
.drop {
  display: block; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--card);
  padding: 30px 20px 18px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.drop .up { width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); color: var(--accent); }
.drop .up svg { width: 22px; height: 22px; }
.drop p { margin: 0 0 16px; color: var(--dim); }
.drop select { height: 32px; font-size: 14px; max-width: 100%; }

/* jobs */
#jobs { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.job { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.head { display: flex; align-items: center; gap: 10px; }
.head .t { flex: 1; min-width: 0; }
.name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--dim); }
.bar { flex: 1; height: 4px; border-radius: 2px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .3s; }
.bar.busy i { width: 35%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
.prog .st { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.err { color: var(--bad); margin-top: 8px; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.err span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.stem { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.play { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; flex: none; }
.play:hover, .stem.on .play { background: var(--accent); color: var(--accent-ink); }
.play svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.lb { width: 3.4em; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wave { flex: 1; min-width: 0; height: 34px; cursor: pointer; display: block; }
.tm { color: var(--dim); font-size: 12px; width: 78px; text-align: right; flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
#more { display: block; margin: 16px auto 0; }
.empty { color: var(--dim); text-align: center; padding: 28px 0; }

/* dialogs, toast */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 20px; width: min(340px, 92vw); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { display: grid; gap: 10px; }
dialog h3 { margin: 0 0 4px; font-size: 16px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 20; max-width: 90vw;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(320px, 100%); display: grid; gap: 12px; }
.login h1 { margin: 0 0 8px; font-size: 26px; text-align: center; letter-spacing: .04em; }
.login input, .login .btn { height: 42px; }
.login .msg { color: var(--bad); font-size: 13px; min-height: 20px; text-align: center; margin: 0; }

/* admin */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h2 small { font-weight: 400; color: var(--dim); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row .grow { flex: 1 1 160px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; color: var(--dim); font-size: 14px; }
.stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.field { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 14px; }
.field input[type=number] { width: 76px; }
.list { list-style: none; margin: 12px 0; padding: 0; border-top: 1px solid var(--line); }
.list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.list li .g { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li small { color: var(--dim); }
.tablewrap { overflow-x: auto; margin: 0 -16px -6px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 400; color: var(--dim); font-size: 13px; }
th, td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
td.w { white-space: normal; overflow-wrap: anywhere; min-width: 160px; }
td:last-child, th:last-child { padding-right: 0; text-align: right; }
td.empty { text-align: center; padding: 22px 0 16px; }
tr:last-child td { border-bottom: 0; }
td a { color: var(--accent); margin-right: 8px; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--dim); }
.pill.done { color: #1a8f4c; background: color-mix(in srgb, #1a8f4c 14%, transparent); }
.pill.failed { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

@media (max-width: 560px) {
  header, main { padding-left: 14px; padding-right: 14px; }
  .tm { width: auto; }
  .stem { gap: 8px; }
}
