:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111418);
  --hint: var(--tg-theme-hint-color, #8a9099);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --danger: var(--tg-theme-destructive-text-color, #d9483b);
  --ok: #2ea043;
  --warn: #c98a00;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 14px 48px; }
h1 { font-size: 22px; margin: 4px 0 6px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.hint { color: var(--hint); font-size: 13.5px; margin: 0; }
header .hint { margin-bottom: 14px; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; gap: 10px; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

button {
  font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--button); color: var(--button-text); font-weight: 600; }
.secondary { background: color-mix(in srgb, var(--button) 14%, transparent); color: var(--link); font-weight: 500; }
.link { background: none; color: var(--link); padding: 6px 0; }
.cancel { color: var(--danger); font-size: 13.5px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 22px 10px;
  border: 2px dashed color-mix(in srgb, var(--hint) 45%, transparent); border-radius: 12px;
  cursor: pointer; text-align: center;
}
.drop.over { border-color: var(--button); }
.drop input { display: none; }
.drop-icon { font-size: 30px; }
.drop-title { font-weight: 600; color: var(--link); font-size: 16px; }
.drop-sub { color: var(--hint); font-size: 13px; }

.chosen { list-style: none; padding: 0; margin: 12px 0; max-height: 220px; overflow: auto; }
.chosen li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--hint) 18%, transparent); font-size: 14px; }
.chosen li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen li span:last-child { color: var(--hint); flex: none; }

.tips { margin-top: 12px; font-size: 13.5px; }
.tips summary { color: var(--link); cursor: pointer; }
.tips ul { margin: 8px 0 0; padding-left: 18px; color: var(--hint); }

.notice { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--warn) 16%, transparent); }
.notice.error { background: color-mix(in srgb, var(--danger) 14%, transparent); }

.section-head { display: flex; justify-content: space-between; align-items: baseline; }
#batch-note { margin: -4px 0 10px; }

.video .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--hint) 20%, transparent); color: var(--hint); }
.badge.processing, .badge.uploading { background: color-mix(in srgb, var(--button) 18%, transparent); color: var(--link); }
.badge.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.failed { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

.bar { height: 6px; border-radius: 99px; margin: 10px 0 6px; overflow: hidden;
  background: color-mix(in srgb, var(--hint) 22%, transparent); }
.bar i { display: block; height: 100%; width: 0; background: var(--button); transition: width .4s; }
.detail { margin-top: 4px; }
.error { color: var(--danger); margin-top: 8px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11.5px; color: var(--hint); }
.stat.good b { color: var(--ok); }
.stat.flag b { color: var(--warn); }
.meta { margin-bottom: 8px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 5px 4px; text-align: left; border-bottom: 1px solid color-mix(in srgb, var(--hint) 16%, transparent); }
th { color: var(--hint); font-weight: 500; font-size: 12px; }
td.num { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; text-align: right; }
.preview { margin: 4px 0 10px; }
.actions { margin-top: 4px; }
.table-wrap { margin-top: 8px; max-height: 420px; overflow: auto; }
.flags { color: var(--warn); font-size: 11.5px; }
tr.clean td:first-child { box-shadow: inset 3px 0 var(--ok); padding-left: 7px; }

.bundle-title { font-weight: 600; margin-bottom: 8px; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { background: var(--card); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px;
  display: flex; justify-content: space-between; gap: 10px; cursor: pointer; }
.history li .when { color: var(--hint); font-size: 13px; flex: none; }

.options { display: grid; gap: 8px; }
.option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: var(--bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--button) 35%, transparent); }
.option b { color: var(--link); font-size: 15px; }
.option span { color: var(--hint); font-size: 12.5px; }
