/* ==========================================================================
   FileHelper · 下载助手 —— 亮色现代风格 / 零外部依赖
   ========================================================================== */

:root {
  --bg-0: #f4f7fc;
  --bg-1: #eef2f8;
  --card: #ffffff;
  --card-2: #f8fafc;
  --card-3: #f1f5f9;
  --line: rgba(15, 23, 42, .1);
  --line-strong: rgba(15, 23, 42, .18);
  --text: #1e293b;
  --text-strong: #0f172a;
  --muted: #64748b;
  --muted-2: #6b7789;
  --primary: #0284c7;
  --accent: #4f46e5;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --grad: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px -18px rgba(15, 23, 42, .18), 0 2px 8px -4px rgba(15, 23, 42, .08);
  --shadow-hover: 0 18px 40px -18px rgba(15, 23, 42, .22), 0 4px 14px -6px rgba(15, 23, 42, .12);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg-0);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(780px 460px at 12% -6%, rgba(56, 189, 248, .1), transparent 62%),
    radial-gradient(720px 460px at 92% 2%, rgba(99, 102, 241, .1), transparent 64%),
    radial-gradient(900px 560px at 50% 112%, rgba(34, 197, 94, .05), transparent 62%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f9 100%);
}

::selection { background: rgba(14, 165, 233, .18); color: #0f172a; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, .18);
  border: 2px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, .28); background-clip: padding-box; }

:focus-visible { outline: 2px solid rgba(2, 132, 199, .65); outline-offset: 2px; }

svg { display: block; }

.ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ico svg { width: 1em; height: 1em; display: block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  color: var(--text);
  text-decoration: none;
  transition: top .18s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 16, 32, .8);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 66px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  color: #e0f2fe;
  background: var(--grad);
  box-shadow: 0 10px 24px -10px rgba(56, 189, 248, .75), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.brand-logo svg { width: 23px; height: 23px; }

.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text-strong);
  white-space: nowrap;
}
.brand-accent {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.brand-sub {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, .07);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: border-color .2s ease, background .2s ease;
}
.stat-pill > svg { width: 15px; height: 15px; color: var(--muted-2); flex: 0 0 auto; }
.stat-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px rgba(100, 116, 139, .16);
  transition: background .2s ease, box-shadow .2s ease;
}

#ssePill[data-state="connecting"] .stat-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .16);
  animation: dot-blink 1.2s ease-in-out infinite;
}
#ssePill[data-state="online"] { border-color: rgba(34, 197, 94, .3); background: rgba(34, 197, 94, .08); }
#ssePill[data-state="online"] .stat-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18), 0 0 10px rgba(34, 197, 94, .7);
}
#ssePill[data-state="offline"] { border-color: rgba(248, 113, 113, .36); background: rgba(248, 113, 113, .08); }
#ssePill[data-state="offline"] .stat-value { color: #fca5a5; }
#ssePill[data-state="offline"] .stat-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, .18);
  animation: dot-blink 1s ease-in-out infinite;
}

#speedPill.is-active { border-color: rgba(56, 189, 248, .32); background: rgba(56, 189, 248, .09); }
#speedPill.is-active > svg { color: var(--primary); }
#speedPill.is-active .stat-value { color: #7dd3fc; }

/* ---------- 布局 ---------- */

.layout {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 44px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card {
  background: linear-gradient(180deg, rgba(17, 26, 46, .94), rgba(17, 26, 46, .8));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.create-card { padding: 20px; }

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

.create-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------- Tabs ---------- */

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(2, 6, 23, .5);
  border: 1px solid var(--line);
}
.tab {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 17px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.tab:hover { color: var(--text); background: rgba(148, 163, 184, .08); }
.tab.is-active {
  color: #e0f2fe;
  background: linear-gradient(135deg, rgba(56, 189, 248, .18), rgba(99, 102, 241, .22));
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .3);
}

.tab-panel { animation: fade-in .2s ease; }

/* ---------- 表单 ---------- */

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

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}
.req { color: var(--danger); font-weight: 700; }

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
}
.field-submit { align-self: end; }

.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, .45);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.input::placeholder { color: var(--muted-2); opacity: .85; }
.input:hover { border-color: rgba(148, 163, 184, .26); }
.input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, .6);
  background: rgba(2, 6, 23, .62);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .14);
}
.input.is-invalid {
  border-color: rgba(248, 113, 113, .62);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, .12);
}
.input:disabled { opacity: .6; cursor: not-allowed; }

.input.has-ico { padding-left: 41px; }
.input.has-count { padding-right: 56px; }

.input-ico {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--muted-2);
  pointer-events: none;
}

.char-count {
  position: absolute;
  right: 12px;
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.char-count.is-max { color: var(--warn); }

.field-error {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 12px;
  color: #fca5a5;
  line-height: 1.4;
}

.field-hint { margin: 0; font-size: 12px; color: var(--muted-2); }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(148, 163, 184, .1);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.btn:hover { background: rgba(148, 163, 184, .16); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; pointer-events: none; }
.btn > svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btn .ico { font-size: 16px; flex: 0 0 auto; }

.btn-primary {
  background: var(--grad);
  color: #04121f;
  box-shadow: 0 9px 22px -10px rgba(56, 189, 248, .8);
}
.btn-primary:hover {
  background: var(--grad);
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -12px rgba(56, 189, 248, .9);
}
.btn-primary:active { transform: translateY(0); filter: brightness(.98); }

.btn-lg { height: 46px; padding: 0 22px; font-size: 14px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn-sm > svg { width: 14px; height: 14px; }
.btn-sm .ico { font-size: 14px; }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { background: rgba(148, 163, 184, .1); border-color: var(--line-strong); color: var(--text); }

.btn-accent {
  background: rgba(56, 189, 248, .1);
  border-color: rgba(56, 189, 248, .32);
  color: #7dd3fc;
}
.btn-accent:hover { background: rgba(56, 189, 248, .18); border-color: rgba(56, 189, 248, .5); color: #bae6fd; }

.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #2a0808;
  box-shadow: 0 9px 22px -10px rgba(248, 113, 113, .7);
}
.btn-danger:hover { filter: brightness(1.06); transform: translateY(-1px); }

.btn-danger-ghost {
  background: rgba(248, 113, 113, .08);
  border-color: rgba(248, 113, 113, .28);
  color: #fca5a5;
}
.btn-danger-ghost:hover { background: rgba(248, 113, 113, .16); border-color: rgba(248, 113, 113, .46); color: #fecaca; }

.btn.is-busy { pointer-events: none; }
.btn.is-busy > svg, .btn.is-busy > .ico { display: none; }
.btn.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}

.icon-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.icon-btn:hover { background: rgba(148, 163, 184, .12); color: var(--text); }
.icon-btn > svg { width: 16px; height: 16px; }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 高级选项 ---------- */

.adv {
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.adv-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .18s ease;
}
.adv-toggle:hover { color: var(--text); }
.adv-toggle svg { width: 15px; height: 15px; transition: transform .2s ease; }
.adv-toggle.is-open svg { transform: rotate(180deg); }

.adv-panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, .34);
  animation: fade-in .18s ease;
}

.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  flex-wrap: wrap;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, .5);
}
.seg-btn {
  min-width: 52px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.seg-btn:hover { background: rgba(148, 163, 184, .1); color: var(--text); }
.seg-btn.is-active {
  color: #e0f2fe;
  background: linear-gradient(135deg, rgba(56, 189, 248, .22), rgba(99, 102, 241, .26));
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .32);
}
.seg-btn:disabled { opacity: .32; cursor: not-allowed; }

/* ---------- 上传 ---------- */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 26px 18px;
  border: 1.5px dashed rgba(148, 163, 184, .28);
  border-radius: 12px;
  background: rgba(2, 6, 23, .28);
  text-align: center;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.dropzone:hover { border-color: rgba(56, 189, 248, .45); background: rgba(56, 189, 248, .05); }
.dropzone.is-dragover {
  border-color: rgba(56, 189, 248, .8);
  background: rgba(56, 189, 248, .1);
  transform: scale(1.005);
}
.dropzone.is-disabled { opacity: .55; pointer-events: none; }

.drop-ico { width: 27px; height: 27px; color: var(--primary); filter: drop-shadow(0 0 12px rgba(56, 189, 248, .4)); }
.drop-title { margin: 0; font-size: 13.5px; color: var(--text); }
.drop-hint { margin: 0; font-size: 12px; color: var(--muted-2); }
.link-like { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 189, 248, .22);
  background: rgba(56, 189, 248, .06);
  animation: fade-in .18s ease;
}
.file-chip-ico { width: 18px; height: 18px; flex: 0 0 auto; color: var(--primary); }
.file-chip-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-chip-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip-size { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, .35);
  animation: fade-in .18s ease;
}
.upload-progress-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.upload-pct { font-weight: 700; color: #7dd3fc; font-variant-numeric: tabular-nums; }
.upload-detail { flex: 1; min-width: 0; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 区块标题 ---------- */

.section { display: flex; flex-direction: column; gap: 12px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text-strong);
}
.section-title::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--grad);
  box-shadow: 0 0 10px rgba(56, 189, 248, .45);
}
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, .1);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 搜索 ---------- */

.search { position: relative; display: flex; align-items: center; width: 240px; max-width: 100%; }
.search-ico {
  position: absolute;
  left: 11px;
  display: flex;
  color: var(--muted-2);
  pointer-events: none;
}
.search-ico svg { width: 15px; height: 15px; }
.search-input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 33px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, .45);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:hover { border-color: rgba(148, 163, 184, .26); }
.search-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, .55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .12);
}
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-clear {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.search-clear:hover { background: rgba(148, 163, 184, .14); color: var(--text); }
.search-clear svg { width: 13px; height: 13px; }

/* ---------- 进行中卡片 ---------- */

.active-list { display: flex; flex-direction: column; gap: 10px; }

.dl-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 16px 16px 19px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 26, 46, .95), rgba(15, 23, 42, .9));
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
  animation: card-in .26s ease;
}
.dl-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--muted-2);
  transition: background .2s ease;
}
.dl-card:hover {
  border-color: rgba(148, 163, 184, .3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.dl-card[data-status="download"]::before, .dl-card[data-status="downloading"]::before { background: linear-gradient(180deg, #38bdf8, #6366f1); }
.dl-card[data-status="uploading"]::before { background: linear-gradient(180deg, #818cf8, #a855f7); }
.dl-card[data-status="queued"]::before { background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.dl-card[data-status="error"]::before { background: linear-gradient(180deg, #f87171, #ef4444); }
.dl-card[data-status="canceled"]::before { background: linear-gradient(180deg, #94a3b8, #64748b); }

.dl-card[data-status="error"] { border-color: rgba(248, 113, 113, .26); }
.dl-card[data-status="error"]:hover { border-color: rgba(248, 113, 113, .42); }

.dl-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.dl-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dl-remark {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .01em;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, .1);
  color: var(--muted);
}
.type-ico svg { width: 19px; height: 19px; }
.type-video { background: rgba(168, 85, 247, .12); border-color: rgba(168, 85, 247, .22); color: #c084fc; }
.type-audio { background: rgba(236, 72, 153, .12); border-color: rgba(236, 72, 153, .22); color: #f472b6; }
.type-image { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .22); color: #4ade80; }
.type-archive { background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .22); color: #fcd34d; }
.type-disk { background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .22); color: #7dd3fc; }
.type-doc { background: rgba(99, 102, 241, .14); border-color: rgba(99, 102, 241, .24); color: #a5b4fc; }
.type-code { background: rgba(20, 184, 166, .12); border-color: rgba(20, 184, 166, .22); color: #5eead4; }
.type-app { background: rgba(249, 115, 22, .12); border-color: rgba(249, 115, 22, .22); color: #fdba74; }
.type-file { background: rgba(148, 163, 184, .1); border-color: var(--line); color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.badge-downloading { color: #7dd3fc; background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .28); }
.badge-downloading::before { animation: dot-blink 1.4s ease-in-out infinite; }
.badge-uploading { color: #c7d2fe; background: rgba(99, 102, 241, .12); border-color: rgba(99, 102, 241, .3); }
.badge-uploading::before { animation: dot-blink 1.4s ease-in-out infinite; }
.badge-queued { color: #fcd34d; background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .26); }
.badge-completed { color: #86efac; background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .26); }
.badge-error { color: #fca5a5; background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); }
.badge-canceled { color: #cbd5e1; background: rgba(148, 163, 184, .1); border-color: rgba(148, 163, 184, .25); }
.badge-unknown { color: var(--muted); background: rgba(148, 163, 184, .1); border-color: var(--line); }

.dl-filename {
  display: block;
  max-width: 100%;
  font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dl-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid rgba(248, 113, 113, .22);
  background: rgba(248, 113, 113, .08);
  color: #fca5a5;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.dl-error .ico { font-size: 15px; margin-top: 1px; flex: 0 0 auto; }
.dl-error-text { min-width: 0; }

.dl-progress { display: flex; align-items: center; gap: 12px; }

.progress {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .13);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #6366f1);
  box-shadow: 0 0 12px rgba(56, 189, 248, .45);
  transition: width .4s cubic-bezier(.22, .61, .36, 1);
}
.is-indeterminate .progress-fill {
  width: 35% !important;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0), #38bdf8 45%, rgba(99, 102, 241, .9) 70%, rgba(56, 189, 248, 0));
  box-shadow: none;
  animation: indeterminate 1.35s ease-in-out infinite;
}
.dl-card[data-status="queued"] .is-indeterminate .progress-fill {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0), #fbbf24 45%, rgba(245, 158, 11, .9) 70%, rgba(251, 191, 36, 0));
}
.dl-card[data-status="error"] .progress-fill {
  background: linear-gradient(90deg, #f87171, #ef4444);
  box-shadow: 0 0 10px rgba(248, 113, 113, .4);
}
.dl-card[data-status="canceled"] .progress-fill {
  background: linear-gradient(90deg, #94a3b8, #64748b);
  box-shadow: none;
}

.dl-pct {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dl-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  font-size: 12px;
  color: var(--muted-2);
}
.fact { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; }
.fact-k { color: var(--muted-2); }
.fact-v { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.fact:first-child .fact-v, .fact:nth-child(2) .fact-v { color: var(--text); }

.dl-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  justify-content: flex-start;
  min-width: 104px;
}

/* ---------- 已完成列表 ---------- */

.done-list {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(17, 26, 46, .72);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.done-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, .08);
  transition: background .16s ease;
  animation: row-in .22s ease;
}
.done-row:last-child { border-bottom: 0; }
.done-row:hover { background: rgba(148, 163, 184, .045); }

.done-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.done-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.done-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.done-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}
.done-actions .btn { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.done-actions .btn > svg { width: 13px; height: 13px; }
.done-actions .ico { font-size: 13px; }

/* ---------- 空态 ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 34px 20px;
  border: 1px dashed rgba(148, 163, 184, .22);
  border-radius: var(--radius);
  background: rgba(17, 26, 46, .34);
  text-align: center;
}
.empty-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 4px;
  border-radius: 16px;
  border: 1px solid rgba(56, 189, 248, .16);
  background: rgba(56, 189, 248, .07);
  color: var(--primary);
}
.empty-ico svg { width: 24px; height: 24px; }
.empty-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.empty-sub { margin: 0; max-width: 360px; font-size: 12.5px; color: var(--muted-2); }
.empty-compact { padding: 24px 16px; }

/* ---------- 页脚 ---------- */

.footer {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  background: rgba(11, 16, 32, .5);
}
.footer-inner {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 22px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted-2);
}
.footer-brand { color: var(--muted); font-weight: 600; }
.footer-brand span { color: var(--muted-2); font-weight: 500; }
.footer-item b { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.footer-sep { width: 3px; height: 3px; border-radius: 50%; background: rgba(148, 163, 184, .35); }
.footer-spacer { flex: 1; }
.footer-hint { color: var(--muted-2); }

/* ---------- Toast ---------- */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  background: rgba(15, 23, 42, .97);
  box-shadow: 0 16px 36px -16px rgba(2, 6, 23, .95);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px) scale(.98);
  transition: opacity .22s ease, transform .22s ease;
}
.toast.is-show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-ico { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-ico { color: var(--danger); }
.toast-info { border-left-color: var(--primary); }
.toast-info .toast-ico { color: var(--primary); }
.toast-ico { font-size: 16px; margin-top: 1px; flex: 0 0 auto; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }

/* ---------- 弹窗 ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, .72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in .16s ease;
}
.modal {
  width: min(430px, 100%);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, .2);
  background: linear-gradient(180deg, #131d33, #101a2d);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .85);
  animation: modal-in .22s cubic-bezier(.22, .61, .36, 1);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-strong); }
.modal-body { margin: 0 0 16px; font-size: 13px; line-height: 1.65; color: var(--muted); overflow-wrap: anywhere; }
.modal-input-wrap { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

body.modal-open { overflow: hidden; }

/* ---------- 其他 ---------- */

.noscript {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 200;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, .4);
  background: #1f1220;
  color: #fecaca;
  font-size: 13px;
}

/* ---------- 动画 ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dot-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(330%); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .field-submit { align-self: stretch; }
  .field-submit .btn-lg { width: 100%; }

  .dl-card { grid-template-columns: minmax(0, 1fr); }
  .dl-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
  }
  .dl-actions .btn { flex: 0 1 auto; }
}

@media (max-width: 640px) {
  .topbar-inner { align-items: flex-start; }
  .stats { width: 100%; gap: 6px; }
  .stat-pill { justify-content: center; padding: 6px 10px; font-size: 12px; }
  .brand-sub { max-width: 60vw; }

  .layout { width: calc(100% - 24px); padding-top: 14px; gap: 16px; }
  .create-card { padding: 16px; }
  .create-head { margin-bottom: 14px; }
  .create-hint { width: 100%; }

  .section-head { align-items: stretch; }
  .search { width: 100%; }

  .done-row { grid-template-columns: auto minmax(0, 1fr); }
  .done-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px dashed rgba(148, 163, 184, .12);
  }
  .done-actions .btn { flex: 0 1 auto; }

  .footer-inner { padding-bottom: 18px; }
  .footer-spacer { display: none; }
  .footer-hint { display: none; }
}

@media (max-width: 440px) {
  .stat-label { display: none; }
  .brand-text h1 { font-size: 16px; }
  .brand-logo { width: 38px; height: 38px; border-radius: 11px; }
  .dl-card { padding: 14px 14px 14px 16px; }
  .dl-remark { font-size: 14px; }
  .dl-facts { gap: 5px 12px; }
  .dl-actions .btn { flex: 1 1 auto; }
  .done-actions .btn { flex: 1 1 auto; }
  .modal { padding: 16px; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; max-width: none; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 浏览器多线程下载面板（public/multidownload.js） ===== */
.mdl-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  width: min(380px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .22);
  background: linear-gradient(180deg, rgba(17, 26, 46, .98), rgba(15, 23, 42, .98));
  box-shadow: 0 18px 48px rgba(2, 6, 23, .55);
  color: #e2e8f0;
  font-size: 13px;
  backdrop-filter: blur(8px);
}
.mdl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mdl-title { font-weight: 600; color: #f8fafc; }
.mdl-cancel {
  border: 1px solid rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .1);
  color: #fca5a5;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.mdl-cancel:hover { background: rgba(248, 113, 113, .18); }
.mdl-cancel[disabled] { opacity: .5; cursor: default; }
.mdl-name { margin-top: 8px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mdl-progress { margin-top: 10px; height: 8px; border-radius: 999px; background: rgba(148, 163, 184, .16); overflow: hidden; }
.mdl-bar { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, #38bdf8, #6366f1); transition: width .2s ease; }
.mdl-meta { margin-top: 8px; color: #94a3b8; font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .mdl-panel { left: 12px; right: 12px; bottom: 12px; width: auto; }
}


/* ==========================================================================
   亮色主题覆盖（页面整体浅色）
   ========================================================================== */
html { background: var(--bg-0); }

.topbar {
  background: rgba(255, 255, 255, .84);
  border-bottom-color: var(--line);
}
.brand-logo { color: #fff; box-shadow: 0 10px 24px -12px rgba(14, 165, 233, .6), inset 0 1px 0 rgba(255, 255, 255, .35); }
.brand-accent {
  background-image: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.stat-pill { background: #fff; border-color: var(--line); }
#ssePill[data-state="online"] { background: rgba(22, 163, 74, .08); border-color: rgba(22, 163, 74, .28); }
#ssePill[data-state="offline"] { background: rgba(220, 38, 38, .07); border-color: rgba(220, 38, 38, .3); }
#ssePill[data-state="offline"] .stat-value { color: #b91c1c; }
#speedPill.is-active { background: rgba(14, 165, 233, .08); border-color: rgba(14, 165, 233, .3); }
#speedPill.is-active .stat-value { color: #0369a1; }

.card { background: #fff; }
.tabs { background: #f1f5f9; }
.tab:hover { background: rgba(15, 23, 42, .05); }
.tab.is-active {
  color: #0369a1;
  background: rgba(14, 165, 233, .1);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, .22);
}

.input,
.search-input { background: #fff; border-color: var(--line); }
.input:hover,
.search-input:hover { border-color: var(--line-strong); }
.input:focus {
  background: #fff;
  border-color: rgba(2, 132, 199, .55);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .14);
}
.search-input:focus { border-color: rgba(2, 132, 199, .5); box-shadow: 0 0 0 3px rgba(14, 165, 233, .12); }
.input::placeholder,
.search-input::placeholder { color: var(--muted-2); }

.adv-panel,
.upload-progress { background: #f8fafc; }
.seg { background: #f1f5f9; }
.seg-btn:hover { background: rgba(15, 23, 42, .05); }
.seg-btn.is-active {
  color: #0369a1;
  background: rgba(14, 165, 233, .1);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, .22);
}
.dropzone {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, .18);
}
.dropzone:hover { background: rgba(14, 165, 233, .04); border-color: rgba(2, 132, 199, .4); }
.dropzone.is-dragover { background: rgba(14, 165, 233, .08); border-color: rgba(2, 132, 199, .65); }

.btn { background: rgba(15, 23, 42, .06); }
.btn:hover { background: rgba(15, 23, 42, .1); }
.btn.btn-primary { background: var(--grad); color: #fff; }
.btn.btn-danger { background: linear-gradient(135deg, #f87171 0%, #dc2626 100%); color: #fff; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: rgba(15, 23, 42, .06); color: var(--text); }
.btn-accent { background: rgba(14, 165, 233, .1); border-color: rgba(14, 165, 233, .28); color: #0369a1; }
.btn-accent:hover { background: rgba(14, 165, 233, .16); border-color: rgba(14, 165, 233, .4); color: #075985; }
.btn-danger-ghost { background: rgba(220, 38, 38, .06); border-color: rgba(220, 38, 38, .22); color: #b91c1c; }
.btn-danger-ghost:hover { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .35); color: #991b1b; }

.field-error { color: #b91c1c; }
.dl-error {
  background: rgba(220, 38, 38, .06);
  border-color: rgba(220, 38, 38, .18);
  color: #b91c1c;
}
.upload-pct { color: #0369a1; }

.dl-card { background: #fff; }
.dl-card:hover { border-color: var(--line-strong); }
.dl-card[data-status="error"] { border-color: rgba(220, 38, 38, .22); }
.dl-card[data-status="error"]:hover { border-color: rgba(220, 38, 38, .38); }

.progress { background: rgba(15, 23, 42, .08); }

.type-video { color: #7e22ce; }
.type-audio { color: #be185d; }
.type-image { color: #15803d; }
.type-archive { color: #b45309; }
.type-disk { color: #0369a1; }
.type-doc { color: #4338ca; }
.type-code { color: #0f766e; }
.type-app { color: #c2410c; }

.badge-downloading { color: #0369a1; }
.badge-uploading { color: #4338ca; }
.badge-queued { color: #b45309; }
.badge-completed { color: #15803d; }
.badge-error { color: #b91c1c; }
.badge-canceled { color: #475569; }

.done-list { background: #fff; }
.done-row { border-bottom-color: rgba(15, 23, 42, .06); }
.done-row:hover { background: rgba(15, 23, 42, .03); }
.empty { background: #f8fafc; border-color: rgba(15, 23, 42, .12); }
.empty-ico { background: rgba(14, 165, 233, .08); border-color: rgba(14, 165, 233, .16); }

.toast {
  background: #fff;
  box-shadow: 0 16px 36px -20px rgba(15, 23, 42, .35);
}
.modal-backdrop { background: rgba(15, 23, 42, .32); }
.modal {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 30px 80px -30px rgba(15, 23, 42, .45);
}
.noscript { background: #fef2f2; color: #b91c1c; }

.mdl-panel {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 18px 48px -24px rgba(15, 23, 42, .35);
  color: var(--text);
}
.mdl-title { color: var(--text-strong); }
.mdl-name { color: var(--muted); }
.mdl-meta { color: var(--muted-2); }
.mdl-progress { background: rgba(15, 23, 42, .08); }
.mdl-cancel {
  border-color: rgba(220, 38, 38, .22);
  background: rgba(220, 38, 38, .06);
  color: #b91c1c;
}
.mdl-cancel:hover { background: rgba(220, 38, 38, .12); }

