:root {
  --bg: #0b1020;
  --bg-soft: #121a2e;
  --panel: #161f38;
  --panel-2: #1c2745;
  --line: #26324f;
  --text: #e8edf7;
  --text-strong: #ffffff;
  --muted: #93a1c0;
  --muted-2: #5d6c8c;
  --brand: #4f8cff;
  --brand-2: #22d3ee;
  --brand-3: #6aa1ff;
  --on-brand: #05132e;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 12px;
  /* 以下为原本硬编码、现已变量化的颜色，便于浅色主题覆盖 */
  --bg-glow: #1b2a52;
  --sidebar-bg: rgba(12, 18, 36, .85);
  --dz-bg: rgba(22, 31, 56, .5);
  --thumb-bg: #0d1426;
  --iconbtn-bg: rgba(10, 15, 30, .85);
  --mask-bg: rgba(3, 7, 18, .78);
  --hover-tint: rgba(255, 255, 255, .03);
  --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  --color-scheme: dark;
}

/* ---------- 浅色主题 ---------- */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #eaeff8;
  --panel: #ffffff;
  --panel-2: #eef2fa;
  --line: #dbe3f0;
  --text: #1b2436;
  --text-strong: #0b1220;
  --muted: #5f6d85;
  --muted-2: #8b98ad;
  --brand: #2f6fe4;
  --brand-2: #0891b2;
  --brand-3: #5b9bff;
  --on-brand: #ffffff;
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --bg-glow: #dfe9fb;
  --sidebar-bg: rgba(255, 255, 255, .9);
  --dz-bg: rgba(255, 255, 255, .6);
  --thumb-bg: #e6ecf7;
  --iconbtn-bg: rgba(255, 255, 255, .92);
  --mask-bg: rgba(20, 30, 50, .45);
  --hover-tint: rgba(0, 0, 0, .03);
  --shadow: 0 10px 30px rgba(20, 40, 80, .16);
  --color-scheme: light;
}

html { color-scheme: var(--color-scheme); }

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-glow) 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100%; }

.sidebar {
  width: 216px;
  flex: none;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; font-weight: 800; color: var(--on-brand);
}
.brand-name { font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  color: var(--muted); border: 1px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79,140,255,.22), rgba(34,211,238,.10));
  border-color: rgba(79,140,255,.4);
  color: var(--text-strong);
}
.nav-item .ico { width: 18px; text-align: center; }

.side-foot { margin-top: auto; font-size: 11px; color: var(--muted-2); padding: 8px; line-height: 1.7; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 20px; margin: 0; }
.spacer { flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 16px; }
.card-title { font-weight: 700; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.card-desc { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.grid { display: grid; gap: 16px; }
.grid.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- 上传区 ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  transition: .18s;
  background: var(--dz-bg);
  cursor: pointer;
}
.dropzone:hover { border-color: rgba(79,140,255,.6); }
.dropzone.over {
  border-color: var(--brand-2);
  background: rgba(34, 211, 238, .09);
  transform: scale(1.005);
}
.dz-ico { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.dz-title { font-size: 16px; font-weight: 600; }
.dz-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.dz-keys { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 2px 7px; font-size: 11.5px; color: var(--muted); background: var(--bg);
}

.queue { margin-top: 14px; display: grid; gap: 8px; }
.q-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  background: var(--bg-soft);
}
.q-thumb { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; background: var(--panel-2); flex: none; }
.q-bar { height: 4px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin-top: 4px; }
.q-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.q-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 结果 ---------- */
.links { display: grid; gap: 8px; margin-top: 12px; }
.link-row { display: flex; gap: 8px; }
.link-row input {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 9px; padding: 7px 14px; cursor: pointer; transition: .15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: rgba(79,140,255,.6); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  border-color: transparent; color: var(--on-brand); font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: rgba(248,113,113,.4); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }

/* ---------- 表单 ---------- */
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.field > .hint { font-size: 11.5px; color: var(--muted-2); }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 11px; width: 100%; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,140,255,.14); }
textarea { resize: vertical; min-height: 76px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; padding: 5px 0; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); position: relative; transition: .18s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--muted); transition: .18s;
}
.switch input:checked + .track { background: rgba(79,140,255,.35); border-color: var(--brand); }
.switch input:checked + .track::after { left: 19px; background: var(--brand); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent;
  font-size: 13.5px; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--hover-tint); }
.tab.active { color: var(--text-strong); border-bottom-color: var(--brand); background: rgba(79,140,255,.10); }

/* ---------- 图库 ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.g-item {
  border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--bg-soft);
  position: relative; transition: .15s;
}
.g-item:hover { transform: translateY(-2px); border-color: rgba(79,140,255,.5); }
.g-item.sel { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(79,140,255,.3); }
.g-img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: var(--thumb-bg); cursor: zoom-in; }
.g-file { width: 100%; aspect-ratio: 4/3; display: grid; place-items: center; font-size: 30px; color: var(--muted); background: var(--thumb-bg); }
.g-meta { padding: 7px 9px; font-size: 11.5px; color: var(--muted); }
.g-meta .n { color: var(--text); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-check {
  position: absolute; top: 8px; left: 8px; width: 20px; height: 20px;
  accent-color: var(--brand); cursor: pointer; z-index: 3;
  /* 加白色描边，深色图片上也能看清 */
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
/* 悬浮操作条：移到图片底部居中横排，避开左上角选框、也不遮挡画面主体 */
.g-acts {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%) translateY(4px);
  display: flex; gap: 5px; padding: 4px 6px; border-radius: 10px;
  background: rgba(12, 18, 32, .82); backdrop-filter: blur(6px);
  opacity: 0; transition: .16s; z-index: 2; pointer-events: none;
}
.g-item:hover .g-acts, .g-item:focus-within .g-acts {
  opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto;
}
.g-acts .icon-btn {
  width: 28px; height: 28px; font-size: 13px; border-radius: 7px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  color: #fff; display: grid; place-items: center; cursor: pointer;
}
.g-acts .icon-btn:hover { background: var(--brand); border-color: var(--brand); }
.icon-btn {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--iconbtn-bg); display: grid; place-items: center; cursor: pointer; font-size: 12px;
}
.icon-btn:hover { border-color: var(--brand); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------- 统计 ---------- */
.kpi { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: var(--bg-soft); }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: .5px; }
.kpi .k { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 8px; }
.bar { flex: 1; background: linear-gradient(180deg, var(--brand), rgba(79,140,255,.25)); border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.bar span { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.bar-x { display: flex; gap: 6px; margin-top: 5px; }
.bar-x i { flex: 1; text-align: center; font-size: 10px; color: var(--muted-2); font-style: normal; }

.list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list-row { display: flex; gap: 10px; padding: 8px 11px; background: var(--bg-soft); font-size: 12.5px; align-items: center; flex-wrap: wrap; }
.list-head { background: var(--panel); color: var(--muted); font-weight: 600; }

.badge { padding: 1px 7px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.10); }
.badge.err { color: var(--err); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.10); }
.badge.info { color: var(--brand-2); border-color: rgba(34,211,238,.35); background: rgba(34,211,238,.10); }

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

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: var(--mask-bg); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  max-width: min(92vw, 1000px); max-height: 88vh; overflow: auto; padding: 18px; width: 100%;
}
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; }

.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 16px; box-shadow: var(--shadow); font-size: 13px;
  animation: pop .2s ease;
}
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(248,113,113,.5); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.wm-grid { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.wm-cell { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-soft); cursor: pointer; font-size: 10px; color: var(--muted); }
.wm-cell.on { border-color: var(--brand); color: var(--text-strong); background: rgba(79,140,255,.2); }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; }
  .side-foot { display: none; }
  .brand { padding: 0 10px 0 0; }
  .main { padding: 16px 14px 60px; }
  .nav-item { white-space: nowrap; }
}

/* ---------- 主题切换（日间 / 夜间） ---------- */
.theme-toggle {
  width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
  transition: .18s; padding: 0;
}
.theme-toggle:hover {
  border-color: var(--brand); transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(79,140,255,.16), rgba(34,211,238,.08));
}
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 19px; height: 19px; display: block; }
/* 太阳：浅色主题下隐藏；月亮：深色主题下隐藏 */
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }
[data-theme="light"] .theme-toggle .ico-sun { display: block; }
[data-theme="light"] .theme-toggle .ico-moon { display: none; }

/* ================= 全选 ================= */
.sel-all {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none; font-size: 13px;
}
.sel-all input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.cdn-flag {
  margin-top: 4px; font-size: 10px; color: var(--brand-2);
  border: 1px solid rgba(34,211,238,.35); border-radius: 4px;
  padding: 0 5px; display: inline-block;
}

/* ================= 图片查看器 ================= */
.viewer-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .92);
  display: flex; flex-direction: column;
}
.viewer-bar {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; background: rgba(20, 24, 34, .96);
  border-top: 1px solid rgba(255,255,255,.08); flex-wrap: wrap;
  /* 悬浮在底部正中间，不占用布局高度，避免挤压图片显示区域 */
  position: relative; z-index: 2;
  box-shadow: 0 -6px 24px rgba(0,0,0,.35);
}
.viewer-name {
  font-size: 13.5px; max-width: 42vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; color: #e8edf7;
}
.viewer-scale {
  min-width: 148px; text-align: center; font-size: 12px;
  color: #93a1c0; cursor: pointer; user-select: none;
  font-variant-numeric: tabular-nums;
}
.viewer-scale:hover { color: #fff; }
.vbtn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  color: #dbe4f5; border-radius: 7px; cursor: pointer; font-size: 13px;
  display: inline-grid; place-items: center; transition: .15s;
}
.vbtn:hover { background: rgba(79,140,255,.28); border-color: var(--brand); color: #fff; }
.vbtn.wide { padding: 0 12px; font-size: 12.5px; }
.vbtn.on { background: rgba(79,140,255,.4); border-color: var(--brand); color: #fff; }
.vsep { width: 1px; height: 20px; background: rgba(255,255,255,.16); margin: 0 4px; }

.viewer-stage {
  flex: 1; overflow: auto; display: grid; place-items: center;
  /* 底部多留空间给工具栏，保证图片不被遮挡 */
  padding: 20px 20px 28px;
  min-height: 0;
}
.viewer-stage img {
  display: block; border-radius: 4px;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
  transform-origin: center center; max-width: none;
  -webkit-user-drag: none;
}
.viewer-tip {
  flex: none; text-align: center; padding: 8px; font-size: 11.5px;
  color: #7b8aa8; background: rgba(20, 24, 34, .96);
  border-top: 1px solid rgba(255,255,255,.08);
}
.viewer-tip b { color: #a9b8d4; }

/* ================= 详细信息面板 ================= */
.detail-modal { max-width: min(94vw, 900px); }
.detail-body { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
@media (max-width: 700px) { .detail-body { grid-template-columns: 1fr; } }
.detail-preview img {
  width: 100%; border-radius: 10px; border: 1px solid var(--line);
  background: var(--thumb-bg); display: block;
}
.d-sec {
  font-weight: 700; font-size: 12.5px; color: var(--muted);
  margin: 14px 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.d-sec:first-child { margin-top: 0; }
.d-row {
  display: grid; grid-template-columns: 96px 1fr; gap: 10px;
  padding: 4px 0; font-size: 12.5px; align-items: start;
}
.d-k { color: var(--muted); }
.d-v { word-break: break-all; }
.d-v.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; }

/* 链接分组 */
.link-group {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg-soft);
}
.link-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.link-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.link-tag {
  flex: none; width: 116px; font-size: 11px; color: var(--muted);
  text-align: right; padding-right: 4px;
}
.link-row input {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 9px; font-size: 11.5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
@media (max-width: 640px) {
  .link-tag { width: auto; text-align: left; }
  .link-row { flex-wrap: wrap; }
}

/* ================= 文件管理 ================= */
.dir-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.dir-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: var(--bg-soft);
}
.dir-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.dir-path {
  font-size: 11.5px; color: var(--brand-2); word-break: break-all;
  line-height: 1.6; margin-bottom: 6px;
}
.dir-meta { font-size: 11.5px; color: var(--muted); }
.warn-line {
  margin-top: 6px; padding: 7px 10px; border-radius: 8px;
  background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.22);
  color: var(--text); font-size: 11.5px; line-height: 1.7;
}

/* ================= 账号管理 ================= */
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg-soft); flex-wrap: wrap;
}
.user-name { font-weight: 600; font-size: 13.5px; }

/* ================= 日志清理 ================= */
.log-clean {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; background: var(--bg-soft);
}
.clean-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 5px 0;
}
.clean-row + .clean-row { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 9px; }
.clean-label { font-size: 12px; color: var(--muted); min-width: 56px; font-weight: 600; }
