:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --accent-hover: #6b9dff;
  --danger: #e5534b;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f0f2f6;
    --border: #e0e4eb;
    --text: #1a1d23;
    --muted: #6b7484;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --shadow: 0 8px 30px rgba(20, 30, 50, .08);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  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.6;
}

.hidden { display: none !important; }

#app { min-height: 100vh; }

/* ---------- 登录 ---------- */
.login-card {
  width: min(400px, calc(100vw - 40px));
  margin: 12vh auto 0;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(37, 99, 235, .35);
}

.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { margin: 0 0 28px; color: var(--muted); font-size: 13px; }

.login-card form { display: flex; flex-direction: column; gap: 16px; }

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

input[type="text"], input[type="password"], input[type="search"], input[readonly] {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

input:focus { border-color: var(--accent); }

button {
  padding: 10px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}

button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
button.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
button.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.error { color: var(--danger); font-size: 13px; margin: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
}

.brand img {
  display: block;
  border-radius: 6px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.badge {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 主体 ---------- */
main {
  width: min(1280px, calc(100vw - 48px));
  margin: 24px auto 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tools input[type="search"] { width: 200px; }

/* ---------- 拖拽区 ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  outline: none;
}

.dz-icon { font-size: 26px; color: var(--accent); line-height: 1; }
.dz-title { margin-top: 10px; font-size: 14px; }
.dz-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 4px;
  margin-top: 14px;
  overflow: hidden;
}

.progress #progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s;
}

.results { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 13px;
}

.result-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .state-ok { color: #34d399; }
.result-row .state-err { color: var(--danger); }
.result-row input { flex: 1; font-size: 12px; }

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

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s;
}

.tile.selected { border-color: var(--accent); }

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile .check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transition: opacity .15s;
}

.tile:hover .check, .tile.selected .check { opacity: 1; }
.tile.selected .check { background: var(--accent); border-color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.pager { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-body {
  position: relative;
  display: flex;
  gap: 0;
  max-width: 1000px;
  width: 100%;
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.modal-body img {
  flex: 1;
  min-width: 0;
  object-fit: contain;
  background: #000;
  max-height: 86vh;
}

.modal-info {
  width: 380px;
  flex-shrink: 0;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-size: 12px; }
.copy-row button { padding: 8px 12px; font-size: 12px; white-space: nowrap; }

.modal-meta { font-size: 12px; color: var(--muted); word-break: break-all; }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .5);
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

#modal-delete { margin-top: auto; }

@media (max-width: 800px) {
  .modal-body { flex-direction: column; overflow-y: auto; }
  .modal-body img { max-height: 45vh; }
  .modal-info { width: 100%; }
  .tools input[type="search"] { width: 100%; }
}