:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e4e8ee;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: var(--surface);
  padding: 36px 32px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card h1 {
  margin: 0;
  font-size: 22px;
  text-align: center;
  color: var(--text);
}
.login-card .subtitle {
  margin: 0 0 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: var(--radius);
  font-size: 15px;
  margin-top: 8px;
  transition: background 0.15s;
}
.login-card button:hover { background: var(--primary-hover); }
.login-card button:disabled { opacity: 0.6; cursor: not-allowed; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; text-align: center; }

/* ============ 主布局 ============ */
.app-layout { display: flex; flex-direction: column; height: 100vh; }
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.header-right { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.breadcrumb { display: flex; align-items: center; gap: 4px; overflow: hidden; flex-wrap: wrap; }
.breadcrumb a {
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.breadcrumb a:hover { background: var(--bg); color: var(--text); }
.breadcrumb a.current { color: var(--text); font-weight: 500; }
.breadcrumb .sep { color: var(--text-muted); }

.app-body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.folder-tree { flex: 1; overflow-y: auto; padding: 8px; }

.tree-node { user-select: none; }
.tree-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.tree-row:hover { background: var(--bg); }
.tree-row.active { background: #eef2ff; color: var(--primary); }
.tree-row .toggle { width: 16px; opacity: 0.6; font-size: 10px; }
.tree-row .icon { color: #f59e0b; }
.tree-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { margin-left: 14px; border-left: 1px dashed var(--border); padding-left: 4px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  position: relative;
}
.drop-hint {
  border: 2px dashed var(--primary);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  color: var(--primary);
  background: #eef2ff;
  margin-bottom: 16px;
  font-weight: 500;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
}
.file-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.file-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.file-thumb img, .file-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.file-thumb .file-icon {
  font-size: 48px;
  color: var(--text-muted);
}
.file-thumb .play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 32px;
}
.file-info { padding: 8px 10px; }
.file-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-card {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-card.large { max-width: 640px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.modal-body input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}
.modal-body input:focus { border-color: var(--primary); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ============ 上传 ============ */
.upload-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  transition: all 0.15s;
}
.upload-drop.dragover { border-color: var(--primary); background: #eef2ff; color: var(--primary); }
.upload-drop p { margin: 8px 0; }
.upload-drop .hint { font-size: 12px; color: var(--text-muted); }

.upload-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.upload-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.upload-item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
  gap: 8px;
}
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.upload-item .status { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.upload-item .status.error { color: var(--danger); }
.upload-item .status.done { color: var(--success); }
.upload-item .actions { display: flex; gap: 4px; }
.upload-item .actions button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.upload-item .actions button:hover { color: var(--text); border-color: var(--text-muted); }
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.2s;
}
.progress-bar .fill.done { background: var(--success); }
.progress-bar .fill.error { background: var(--danger); }

/* ============ 移动目标列表 ============ */
.move-target-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.move-target-list .item {
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.move-target-list .item:hover { background: var(--bg); }
.move-target-list .item.selected { background: #eef2ff; color: var(--primary); }
.move-target-list .item.root { color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ============ 预览 ============ */
.preview-modal { padding: 0; }
.preview-card {
  background: var(--surface);
  width: 90vw;
  height: 90vh;
  border-radius: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-card .modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-content {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preview-content img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-content video { max-width: 100%; max-height: 100%; }
.preview-meta {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.preview-meta .info { flex: 1; min-width: 0; }
.preview-meta .info .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta .info .sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.preview-meta .url-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.preview-meta input {
  flex: 1;
  min-width: 200px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg);
}

/* ============ 右键菜单 ============ */
.ctx-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 160px;
  z-index: 200;
}
.ctx-menu .item {
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctx-menu .item:hover { background: var(--bg); }
.ctx-menu .item.danger { color: var(--danger); }
.ctx-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 300;
  box-shadow: var(--shadow-lg);
}
.toast.error { background: rgba(220, 38, 38, 0.95); }
.toast.success { background: rgba(22, 163, 74, 0.95); }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .header-right .btn span { display: none; }
}
