/* ================= yt-dlp 下载器 · 界面样式 ================= */

:root {
  --bg: #0e1116;
  --bg-soft: #141922;
  --panel: #171d26;
  --panel-2: #1d2430;
  --border: #262f3d;
  --border-soft: #212936;
  --text: #e7edf6;
  --text-dim: #9aa7ba;
  --text-mute: #6c7a8d;
  --accent: #4f8cff;
  --accent-2: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* 必须放在最前：作者样式里的 display 会盖掉 UA 的 [hidden]，这里强制生效 */
[hidden] { display: none !important; }

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

body {
  background-image:
    radial-gradient(900px 500px at 12% -12%, rgba(79, 140, 255, .16), transparent 62%),
    radial-gradient(760px 460px at 92% -6%, rgba(139, 92, 246, .14), transparent 62%);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: 40px;
}

h2 { font-size: 15px; margin: 0; letter-spacing: .2px; }
h3 { font-size: 16px; margin: 0; }
a { color: var(--accent); }

svg { flex: none; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(14, 17, 22, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.brand { display: flex; align-items: center; gap: 11px; }
.logo { display: grid; place-items: center; }
.brand-text { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.brand-text strong { font-size: 15px; letter-spacing: .3px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge-ok { color: var(--ok); border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .08); }
.badge-warn { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }

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

main {
  max-width: 1120px;
  margin: 20px auto 0;
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
}

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

.hint { color: var(--text-mute); font-size: 12.5px; }
.count {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.row { display: flex; align-items: center; gap: 9px; }
.row-wrap { flex-wrap: wrap; }
.row-dir { align-items: flex-end; gap: 9px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border-soft); margin: 14px 0; }

/* ---------------- 表单控件 ---------------- */

.input {
  width: 100%;
  background: #10151d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:hover { border-color: #33405280; }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .16);
  background: #0d1219;
}
.input::placeholder { color: #55637a; }

select.input {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa7ba' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 13px;
  cursor: pointer;
}
select.input option { background: #141a23; color: var(--text); }

.url-input {
  resize: vertical;
  min-height: 74px;
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 132px; }
.field > span { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.field-grow { flex: 1; min-width: 240px; }
.field-inline { flex-direction: row; align-items: center; gap: 7px; }
.input-sm { width: 92px; }

.opts { align-items: flex-end; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s, opacity .15s;
}
.btn:hover { background: #232c3a; border-color: #33404f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(79, 140, 255, .28);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 13.5px; }
.btn-icon { padding: 5px 9px; font-size: 14px; line-height: 1; }

/* ---------------- 复选 chips ---------------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #10151d;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: #33404f; color: var(--text); }
.chip input { accent-color: var(--accent); margin: 0; cursor: pointer; }
.chip:has(input:checked) {
  color: var(--text);
  border-color: rgba(79, 140, 255, .55);
  background: rgba(79, 140, 255, .1);
}

/* ---------------- 解析结果 ---------------- */

.result { display: flex; gap: 15px; align-items: flex-start; }
.result-thumb {
  position: relative;
  width: 190px;
  flex: none;
  aspect-ratio: 16 / 9;
  background: #0d1219;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.result-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--text-mute); font-size: 12px;
}
.thumb-dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0, 0, 0, .78);
  color: #fff; font-size: 11.5px;
  padding: 1px 6px; border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.result-info { min-width: 0; flex: 1; }
.result-info h3 {
  font-size: 14.5px;
  line-height: 1.45;
  margin-bottom: 7px;
  word-break: break-word;
}
.meta { color: var(--text-dim); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 5px 14px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 9px;
  border-radius: 999px;
}
.tag-run { cursor: pointer; }
.tag-run:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- 任务 / 历史 列表 ---------------- */

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

.task {
  display: flex;
  gap: 12px;
  background: #12171f;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 11px 13px;
  transition: border-color .2s;
}
.task:hover { border-color: var(--border); }
.task.is-downloading { border-color: rgba(79, 140, 255, .42); }
.task.is-done { border-color: rgba(52, 211, 153, .3); }
.task.is-error { border-color: rgba(248, 113, 113, .38); }

.task-thumb {
  width: 104px; flex: none;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1219;
  border: 1px solid var(--border-soft);
  align-self: center;
}
.task-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.task-title {
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-sub { display: flex; flex-wrap: wrap; gap: 4px 13px; font-size: 12px; color: var(--text-mute); }
.task-actions { display: flex; gap: 6px; flex: none; }

.pill {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.pill-downloading { color: #9dc0ff; border-color: rgba(79, 140, 255, .45); background: rgba(79, 140, 255, .12); }
.pill-processing { color: #c4b5fd; border-color: rgba(139, 92, 246, .45); background: rgba(139, 92, 246, .12); }
.pill-completed { color: var(--ok); border-color: rgba(52, 211, 153, .42); background: rgba(52, 211, 153, .1); }
.pill-error { color: var(--err); border-color: rgba(248, 113, 113, .42); background: rgba(248, 113, 113, .1); }
.pill-canceled, .pill-queued { color: var(--text-mute); }

.progress {
  height: 7px;
  border-radius: 999px;
  background: #0b0f15;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s ease;
  background-size: 200% 100%;
  animation: flow 2.4s linear infinite;
}
.progress-fill.done { background: linear-gradient(90deg, #22a06b, var(--ok)); animation: none; }
.progress-fill.fail { background: linear-gradient(90deg, #b91c1c, var(--err)); animation: none; }
@keyframes flow { from { background-position: 0 0; } to { background-position: 200% 0; } }

.err-text { color: var(--err); font-size: 12px; word-break: break-word; }

.list-compact .task { padding: 8px 11px; }
.his-title { font-size: 12.8px; word-break: break-word; }
.his-path { font-size: 11.5px; color: var(--text-mute); word-break: break-all; }

.empty {
  color: var(--text-mute);
  font-size: 13px;
  text-align: center;
  padding: 26px 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, .12);
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 8, 12, .72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 660px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1a212c, #141a23);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  overflow: hidden;
  animation: pop .16s ease;
}
.modal-wide { max-width: 900px; }
@keyframes pop { from { transform: translateY(10px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-body { padding: 16px 18px; overflow: auto; min-height: 0; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  background: rgba(0, 0, 0, .16);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

.log {
  margin: 0;
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #c8d3e2;
  background: #0b0f15;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  max-height: 58vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------- 提示条 ---------------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: 380px;
}
.toast {
  background: #1b2330;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide .2s ease;
  word-break: break-word;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }

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

.footer {
  max-width: 1120px;
  margin: 20px auto 0;
  padding: 0 18px;
  color: var(--text-mute);
  font-size: 12px;
  text-align: center;
}

/* ---------------- 滚动条 ---------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3442; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4759; background-clip: content-box; }

/* ---------------- 窄屏 ---------------- */

@media (max-width: 720px) {
  .result { flex-direction: column; }
  .result-thumb { width: 100%; }
  .task-thumb { display: none; }
  .topbar { padding: 10px 14px; }
  .brand-text strong { font-size: 14px; }
  .topbar-actions .btn span { display: none; }
}

/* ---------------- 登录页 ---------------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 384px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.login-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  text-align: center;
}
.login-head h1 { font-size: 17px; margin: 6px 0 0; letter-spacing: .5px; }
.login-head .hint { margin: 0; }

.login-err {
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .45);
  color: #fca5a5;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12.5px;
  word-break: break-word;
}

.login-submit { justify-content: center; margin-top: 2px; }
.login-tip { text-align: center; margin: 0; font-size: 12px; }
.login-tip code {
  background: #10151d;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11.5px;
}

/* 文件列表里用 <a> 做下载按钮 */
a.btn { text-decoration: none; color: var(--text); }
a.btn:hover { color: var(--text); }

.badge-warn-soft { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }

