:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --card: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #374151;
    --primary: #3b82f6;
    --primary-soft: #1e3a5f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

button, .btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--primary); background: var(--primary); color: #fff;
  border-radius: var(--radius); padding: 6px 14px; font-size: 14px; cursor: pointer;
  white-space: nowrap;
}
button:disabled { opacity: .6; cursor: default; }
button.secondary, .btn.secondary { background: var(--card); color: var(--text); border-color: var(--line); }
button.ghost { background: transparent; color: var(--text); border-color: transparent; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.small { padding: 3px 10px; font-size: 12px; }
input[type=text], input[type=password], input[type=search] {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--radius); padding: 8px 12px; font-size: 14px; outline: none;
}
input:focus { border-color: var(--primary); }
input.full { width: 100%; }

/* ---------- 登录 ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 12px;
  padding: 32px 28px; box-shadow: 0 10px 30px rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-card .logo { font-size: 44px; line-height: 1; color: var(--primary); }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card button { justify-content: center; padding: 10px; }
.error { color: var(--danger); min-height: 1.5em; }
.limit { text-align: left; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.limit ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; max-height: 180px; overflow: auto; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; }
.top-actions { margin-left: auto; display: flex; gap: 4px; }

.usage { display: flex; align-items: center; gap: 10px; padding: 8px 20px; font-size: 12px; color: var(--muted); }
.usage-bar { flex: 0 0 200px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#usage-fill { height: 100%; width: 0; background: var(--primary); transition: width .3s; }
#usage-fill.warn { background: var(--warn); }
#usage-fill.danger { background: var(--danger); }

main { padding: 0 20px 120px; max-width: 1200px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 12px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 15px; min-width: 0; }
.crumbs a { color: var(--text); }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { color: var(--muted); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }

.selbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--primary-soft); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px;
}
.selbar span { margin-right: 8px; }

/* ---------- 文件列表 ---------- */
.list { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.list-head, .row {
  display: grid; grid-template-columns: 36px 1fr 110px 150px 36px; align-items: center;
  padding: 0 12px; min-height: 44px; border-bottom: 1px solid var(--line);
}
.list-head { color: var(--muted); font-size: 12px; min-height: 36px; }
.list-head::after { content: ""; }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg); }
.row.sel { background: var(--primary-soft); }
.cb { display: flex; align-items: center; justify-content: center; height: 100%; cursor: pointer; }
.cb input { width: 16px; height: 16px; cursor: pointer; }
.col-name { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.col-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-name:hover { color: var(--primary); }
.ico { font-size: 18px; flex: none; }
.col-size, .col-time { color: var(--muted); font-size: 12px; }
.row-dl { color: var(--muted); text-align: center; }
.row-dl:hover { color: var(--primary); }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ---------- 拖拽 ---------- */
.drop-mask {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: rgba(37, 99, 235, .12); border: 3px dashed var(--primary); pointer-events: none;
}
.drop-mask.show { display: flex; }
.drop-mask div { background: var(--card); padding: 16px 28px; border-radius: 12px; font-size: 16px; }

/* ---------- 上传队列 ---------- */
.uploads {
  position: fixed; right: 20px; bottom: 20px; z-index: 30; width: 380px; max-height: 50vh;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); display: flex; flex-direction: column;
}
.uploads header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
#up-list { overflow: auto; }
.up-row { display: grid; grid-template-columns: 1fr 80px 64px 28px; gap: 8px; align-items: center; padding: 6px 12px; font-size: 12px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.up-bar div { height: 100%; width: 0; background: var(--primary); }
.up-status { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row.done .up-bar div { background: var(--ok); }
.up-row.failed .up-status { color: var(--danger); }
.up-row.failed .up-bar div { background: var(--danger); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card {
  background: var(--card); border-radius: 12px; width: 100%; max-width: 460px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide .modal-card { max-width: 960px; }
.modal-card header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-card h3 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#modal-body { padding: 16px; overflow: auto; }
#modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
#modal-foot:empty { display: none; }
.preview { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; }
.preview-frame { width: 100%; height: 70vh; border: none; }
.preview-text { margin: 0; white-space: pre-wrap; word-break: break-all; font: 13px/1.6 ui-monospace, Consolas, monospace; max-height: 70vh; overflow: auto; }
.picker-path { color: var(--muted); margin-bottom: 8px; word-break: break-all; }
.picker { display: flex; flex-direction: column; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.picker a { padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.picker a:hover { background: var(--bg); }
.picker p { padding: 8px 12px; margin: 0; }

.devices > p { margin-top: 0; }
.dev { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.dev.current strong { color: var(--primary); }
.dev-actions { display: flex; gap: 4px; flex: none; }
.tag { font-size: 11px; background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 60;
  background: rgba(17,24,39,.9); color: #fff; padding: 8px 18px; border-radius: 20px; max-width: 90vw;
}
.toast.err { background: var(--danger); }

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .usage { padding: 6px 12px; }
  .usage-bar { flex-basis: 90px; }
  main { padding: 0 12px 120px; }
  .tools button { padding: 6px 10px; font-size: 13px; }
  .list-head, .row { grid-template-columns: 32px 1fr 70px 32px; padding: 0 6px; }
  .col-time { display: none; }
  .uploads { left: 12px; right: 12px; bottom: 12px; width: auto; }
}
