/* ========== 本地媒体库 - 浅色主题 ========== */
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --warn: #d97706;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .14), 0 20px 60px rgba(16, 24, 40, .18);
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .3px;
}

.toolbar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

#search:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

#sort {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

.actions { display: flex; gap: 10px; }

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}

.btn:hover { background: var(--bg); border-color: #d1d5db; }
.btn:active { transform: scale(.97); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.danger:hover { background: #b91c1c; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  line-height: 1;
}

.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- 顶部访问提示条 ---------- */
.lan-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 20px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}

.lan-bar a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}

.lan-bar a:hover { text-decoration: underline; }

/* ---------- 筛选栏 ---------- */
.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px 4px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.checked { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.stats {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

/* ---------- 多选模式 ---------- */
.multi-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 235, .25);
  border-radius: 999px;
  padding: 5px 8px 5px 16px;
}

.multi-info {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.multi-info b { color: var(--accent); font-size: 15px; }

.multi-hint { color: var(--muted); font-size: 12px; white-space: nowrap; }

.multi-bar .btn { padding: 5px 14px; font-size: 12.5px; }

.check-box {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 5;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  border: 2px solid var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

body.multi-mode .check-box { display: flex; }

.card.selected { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.card.selected .check-box { background: var(--accent); }

/* ---------- 卡片（竖卡片网格，视频在左、图片在右） ---------- */
main#grid {
  padding: 16px 20px 30px;
  display: grid;
  grid-template-columns: 1fr 1fr; /* 视频在左、图片在右 */
  gap: 20px;
  align-items: start;
}

/* 视频 / 图片分区区块 */
.media-section { margin-bottom: 16px; min-width: 0; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  margin: 4px 0 12px;
}

.section-title .count {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  position: relative;
  animation: pop .25s ease;
  min-width: 0; /* 防止内容把网格列撑开 */
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #e8ecf3;
  overflow: hidden;
}

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

.no-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #c3ccd9;
  background: linear-gradient(135deg, #eef1f7, #e3e8f0);
}

.play-ico {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .35);
  opacity: 0;
  transition: opacity .18s;
  pointer-events: none;
}

.play-ico span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  color: var(--accent);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}

.card:hover .play-ico { opacity: 1; }

.duration {
  position: absolute;
  right: 7px;
  bottom: 7px;
  background: rgba(15, 23, 42, .78);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: .3px;
}

.badge-unplayable {
  position: absolute;
  left: 7px;
  top: 7px;
  background: var(--warn);
  color: #fff;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 6px;
}

.card-body { padding: 8px 10px 10px; }

.card-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-name.renaming input {
  width: 100%;
  font-size: 13px;
  padding: 3px 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  outline: none;
}

/* 卡片底部信息：大小 · 分类 */
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.card-meta .cat {
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
}

/* 悬浮操作按钮（缩略图右上角） */
.card-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  display: none;
  gap: 4px;
}

.card:hover .card-actions { display: flex; }

.mini-btn {
  border: none;
  background: rgba(255, 255, 255, .95);
  color: var(--text);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.mini-btn:hover { background: #fff; }
.mini-btn.del:hover { color: var(--danger); }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.empty-icon { font-size: 58px; margin-bottom: 12px; }
.empty p { font-size: 16px; font-weight: 600; margin: 6px 0; color: var(--text); }
.empty .sub { font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.9; }

/* ---------- 页脚 ---------- */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px 18px;
  color: var(--faint);
  font-size: 12px;
  flex-wrap: wrap;
}

/* ---------- 上传进度队列 ---------- */
.upload-queue {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 320px;
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.upload-item {
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 9px 12px;
  animation: pop .2s ease;
}

.u-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.u-bar {
  height: 5px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.u-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .2s;
}

.u-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

.u-pct {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
}

.u-item.done .u-fill { background: var(--ok); }
.u-item.done .u-pct { color: var(--ok); }
.u-item.fail .u-fill { background: var(--danger); }
.u-item.fail .u-pct { color: var(--danger); }

/* ---------- 弹窗（播放器 / 灯箱） ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 940px;
  overflow: hidden;
  animation: pop .2s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}

.player-modal video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 180px);
  background: #000;
}

.modal-tip {
  padding: 8px 16px 12px;
  font-size: 12px;
  color: var(--faint);
}

/* 图片灯箱 */
.photo-modal { max-width: 90vw; width: auto; }
.photo-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  max-height: calc(100vh - 190px);
  overflow: hidden;
}

.photo-stage img {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  cursor: zoom-in;
  transition: transform .25s ease;
  user-select: none;
}

.photo-stage img.zoomed {
  transform: scale(1.8);
  cursor: zoom-out;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border: none;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  border-radius: 10px;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover { background: rgba(255, 255, 255, .3); }
.nav-left { left: 14px; }
.nav-right { right: 14px; }

.photo-tip { text-align: center; }

/* ---------- 删除确认 ---------- */
.confirm-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px 18px;
  width: 360px;
  max-width: 90vw;
  animation: pop .2s ease;
}

.confirm-text {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-all;
}

.confirm-text b { color: var(--danger); }

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- 拖拽提示层 ---------- */
body.dragging::after {
  content: "松开鼠标即可导入";
  position: fixed;
  inset: 12px;
  z-index: 300;
  border: 3px dashed var(--accent);
  border-radius: 18px;
  background: rgba(37, 99, 235, .07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  main#grid { grid-template-columns: 1fr; } /* 窄屏时左右栏改为上下堆叠 */
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .toolbar { order: 3; flex-basis: 100%; max-width: none; }
  .stats { display: none; }
  main#grid { padding: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .upload-queue { width: calc(100vw - 36px); }
}

/* ---------- 访问密码 ---------- */
.foot-actions { display: flex; gap: 14px; }

.link-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}

.link-btn:hover { color: var(--accent); }

.pw-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 20px;
  width: 340px;
  max-width: 90vw;
  text-align: center;
  animation: pop .2s ease;
}

.pw-head { font-size: 34px; margin-bottom: 8px; }

.pw-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
}

.pw-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.pw-input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.pw-error {
  color: var(--danger);
  font-size: 12.5px;
  margin: 2px 0 10px;
  text-align: left;
}

.pw-actions { display: flex; justify-content: flex-end; gap: 10px; }

.pw-tip {
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.7;
  text-align: left;
}
