:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #14171c;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1e232b;
    --border: #2a303a;
    --text: #e8eaed;
    --muted: #98a2b3;
    --accent: #3b82f6;
    --ok: #22c55e;
    --warn: #f59e0b;
    --err: #ef4444;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }
.loading { display: grid; place-items: center; color: var(--muted); }

.wrap { max-width: 900px; margin: 0 auto; padding: 24px 18px 80px; }
.wrap.narrow { max-width: 460px; padding-top: 12vh; }

header.bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
}
header.bar h1 { font-size: 19px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
header.bar .sub { color: var(--muted); font-size: 13px; }
header.bar .spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 620; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=password], select {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

button {
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); transition: filter .12s;
}
button:hover:not(:disabled) { filter: brightness(.96); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
button.danger { color: var(--err); }
button.small { padding: 5px 10px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 180px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tabs button { border-radius: 999px; }
.tabs button[aria-selected=true] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* ---- 拖放区 ---- */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; color: var(--muted);
  background: var(--surface); cursor: pointer; transition: all .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--surface-2); color: var(--text); }
.drop strong { display: block; font-size: 16px; color: var(--text); margin-bottom: 14px; }
.drop .hint { font-size: 13px; margin-top: 14px; line-height: 1.7; }

.drop .picks { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.drop .picks button { padding: 11px 20px; font-size: 15px; }
.drop .hint b { color: var(--text); font-weight: 600; }

/* 手机上按钮要够大好点，桌面上才提示拖放 */
.drop .dragtip { display: none; }
@media (hover: hover) and (pointer: fine) {
  .drop .dragtip { display: block; }
  .drop { padding: 32px 20px; }
}
@media (max-width: 460px) {
  .drop { padding: 26px 14px; }
  .drop .picks { display: grid; grid-template-columns: 1fr 1fr; }
  .drop .picks button { width: 100%; padding: 13px 6px; }
}

/* ---- 预览弹窗 ---- */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .82);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal .mbox {
  max-width: min(980px, 100%); width: 100%;
  display: flex; flex-direction: column; gap: 10px;
}
.modal video, .modal img {
  width: 100%; max-height: 76vh; object-fit: contain;
  background: #000; border-radius: 10px; display: block;
}
.modal .mbar {
  display: flex; align-items: center; gap: 12px;
  color: #fff; font-size: 13.5px;
}
.modal .mname {
  flex: 1; word-break: break-all; opacity: .9;
}
.modal .mbar button { background: rgba(255, 255, 255, .16); color: #fff; border-color: transparent; }

/* 缩略图上的播放提示 */
.tile .thumb[data-play] { cursor: pointer; }
.tile .play {
  position: absolute; inset: 0; margin: auto;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0, 0, 0, .5); color: #fff;
  display: grid; place-items: center; font-size: 17px;
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
.tile .thumb:hover .play { opacity: 1; }
@media (hover: none) {
  .tile .play { opacity: .82; }   /* 手机没有 hover，常驻显示 */
}

/* ---- 上传任务 ---- */
.job {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-top: 10px;
}
.job .top { display: flex; gap: 10px; align-items: baseline; }
.job .name {
  flex: 1; font-size: 14px; font-weight: 550; word-break: break-all;
}
.job .pct { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.job .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.job .meta .state.ok { color: var(--ok); }
.job .meta .state.err { color: var(--err); }
.job .meta .state.warn { color: var(--warn); }

.track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 9px; }
.track > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s; }
.job.done .track > i { background: var(--ok); }
.job.error .track > i { background: var(--err); }

/* ---- 素材网格 ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.tile {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); overflow: hidden;
}

.tile .thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0b0d11;
  display: grid; place-items: center;
  overflow: hidden;
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .noimg { font-size: 30px; opacity: .45; }

.tile .dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0, 0, 0, .78); color: #fff;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 4px; line-height: 1.5;
}

.tile .tbody { padding: 9px 10px 4px; flex: 1; min-width: 0; }
.tile .tname {
  font-size: 13px; font-weight: 550; line-height: 1.35;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-all;
}
.tile .tmeta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.tile .tacts { display: flex; gap: 6px; padding: 8px 10px 10px; }
.tile .tacts a { text-decoration: none; }

@media (max-width: 460px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

/* ---- 列表 ---- */
.files { list-style: none; margin: 0; padding: 0; }
.files li {
  display: flex; gap: 12px; align-items: center; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.files li:last-child { border-bottom: 0; }
.files .fname { flex: 1; word-break: break-all; font-size: 14px; }
.files .fmeta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.files a.dl { text-decoration: none; }

.empty { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}

.linkbox {
  display: flex; gap: 8px; align-items: center; margin-top: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 8px 7px 12px;
}
.linkbox code {
  flex: 1; font-size: 12.5px; overflow-x: auto; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.notice { padding: 11px 14px; border-radius: 9px; font-size: 13.5px; margin-bottom: 14px; }
.notice.err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.notice.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.notice.info { background: var(--surface-2); color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

@media (max-width: 560px) {
  .wrap { padding: 16px 14px 60px; }
  .files li { flex-wrap: wrap; }
}
