:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #7a8294;
  --border: #e6e9f0;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(31, 36, 48, 0.08);
}

.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 100px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 40px));
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  background: #1f2937;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .22);
  font-size: 14px;
  line-height: 1.5;
}

.load-more {
  display: block;
  margin: 16px auto 4px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 100%);
}
.login-card {
  background: var(--card);
  padding: 40px 36px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-logo { font-size: 48px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-sub { margin: 0; color: var(--muted); font-size: 14px; }
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.login-card button:hover { background: var(--accent-2); }
.login-error { margin: 0; color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.breadcrumb a {
  color: var(--accent-2);
  text-decoration: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.breadcrumb a:hover { background: #eef2ff; }
.breadcrumb .sep { color: var(--muted); }
.spacer { flex: 1; }
.topbar input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  width: 200px;
}
.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}
.btn:hover { background: #f0f2f7; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }

.selection-bar {
  position: sticky;
  top: 65px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid #bfdbfe;
  background: #eff6ff;
}
.selection-bar span { font-size: 14px; color: #1d4ed8; font-weight: 600; }

/* ---------- 文件区 ---------- */
.file-area {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px 80px;
}
.drop-hint {
  text-align: center;
  color: var(--muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: all .15s;
}
.drop-hint.over { border-color: var(--accent); background: #eef2ff; color: var(--accent-2); }
.file-list { display: flex; flex-direction: column; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--card);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(31,36,48,.04);
  transition: background-color .12s, opacity .12s;
  content-visibility: auto;
  contain-intrinsic-size: auto 54px;
}
.row:hover { background: #f7f9fd; }
.row.selected { outline: 2px solid #93c5fd; background: #eff6ff; }
.row.pending { opacity: .62; cursor: wait; pointer-events: auto; }
.row.pending .name::after { content: '（处理中…）'; color: var(--muted); font-size: 12px; }
.row-select { width: 17px; height: 17px; flex: none; accent-color: var(--accent); }
.row-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.row .icon { font-size: 22px; flex: none; }
.row .thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; flex: none; background: #eef0f5; }
.row .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.row-more {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  padding: 2px 8px;
  border-radius: 8px;
  flex: none;
}
.row-more:hover { background: #eef0f5; color: var(--text); }

.file-list.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.grid-view .row {
  position: relative;
  min-height: 150px;
  padding: 18px 12px 14px;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  contain-intrinsic-size: auto 150px;
}
.grid-view .row-main { flex-direction: column; justify-content: center; width: 100%; }
.grid-view .row .icon { font-size: 44px; }
.grid-view .row .thumb { width: 76px; height: 76px; border-radius: 10px; }
.grid-view .row .name { max-width: 100%; }
.grid-view .row .meta { white-space: normal; line-height: 1.45; }
.grid-view .row-select { position: absolute; top: 10px; left: 10px; }
.grid-view .row-more { position: absolute; top: 6px; right: 6px; }

/* ---------- 右键菜单 ---------- */
.ctx-menu {
  position: fixed;
  z-index: 50;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 150px;
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  border-radius: 7px;
}
.ctx-menu button:hover { background: #f0f2f7; }
.ctx-menu button.danger { color: var(--danger); }

/* ---------- 进度条 ---------- */
.progress-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 40;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-wrap span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-wrap progress { width: 100%; }
.progress-actions { display: flex; justify-content: flex-end; gap: 8px; }
.progress-actions .btn { padding: 5px 10px; font-size: 12px; }

/* ---------- 预览 ---------- */
.preview {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 18, 26, 0.92);
  display: flex;
  flex-direction: column;
}
.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  color: #fff;
}
.preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 0 20px 20px;
}
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.preview-body pre {
  background: #1a1e28;
  color: #e6e9f0;
  padding: 20px;
  border-radius: 10px;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.preview-empty { color: #cfd4df; text-align: center; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 20px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 18, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px;
  width: 400px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow: auto;
}
.modal-card.wide { width: 640px; }
.modal-card h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); margin: 0; font-size: 13px; word-break: break-all; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  color: var(--text);
}
.field input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
#share-result { display: flex; gap: 8px; }
#share-result input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
}

/* ---------- 我的分享列表 ---------- */
.shares-list { display: flex; flex-direction: column; gap: 10px; }
.share-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-item .top { display: flex; align-items: center; gap: 10px; }
.share-item .top .name { font-weight: 600; flex: 1; word-break: break-all; }
.share-item .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; background: #eef2ff; color: var(--accent-2); padding: 2px 8px; border-radius: 999px; }
.tag.warn { background: #fef3c7; color: #b45309; }
.share-item .url { font-size: 12px; color: var(--muted); word-break: break-all; }
.share-item .actions { display: flex; gap: 8px; }

@media (max-width: 640px) {
  .topbar { gap: 7px; padding: 9px 10px; }
  .topbar input[type="search"] { order: 3; width: 100%; }
  .brand { display: none; }
  .breadcrumb { flex: 1; min-width: 120px; font-size: 13px; }
  .topbar .btn { padding: 7px 9px; font-size: 12px; }
  .selection-bar { top: 0; flex-wrap: wrap; padding: 7px 10px; }
  .selection-bar .btn { padding: 6px 9px; font-size: 12px; }
  .file-area { margin: 12px auto; padding-inline: 10px; }
  .drop-hint { padding: 12px; margin-bottom: 10px; font-size: 13px; }
  .row { gap: 7px; padding: 9px 8px; }
  .row-main { gap: 8px; flex-wrap: wrap; }
  .row .meta { white-space: normal; }
  .file-list.grid-view { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .grid-view .row { min-height: 135px; }
  .progress-wrap { left: 10px; right: 10px; bottom: 10px; width: auto; }
  .toast-wrap { left: 10px; right: 10px; bottom: 110px; max-width: none; }
  .modal { padding: 10px; }
  .modal-card { padding: 20px 16px; max-height: calc(100vh - 20px); overflow: auto; }
}
