:root {
  --bg: #0b0f17;
  --bg-soft: #111827;
  --card: #151c2c;
  --card-hover: #1a2334;
  --border: #24304a;
  --border-soft: #1d2740;
  --text: #e6ecf7;
  --muted: #8b9ab4;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --success: #35d07f;
  --warn: #f5b544;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #17223a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 18px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f8cff, #7a5cff);
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
  box-shadow: 0 8px 20px rgba(79, 140, 255, .3);
}

.brand-text h1 { margin: 0; font-size: 19px; font-weight: 650; }
.brand-text .sub { margin: 0; color: var(--muted); font-size: 12.5px; }

.topbar-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { background: var(--card-hover); border-color: #33436b; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #4f8cff, #6f6bff); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .4); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.push-right { margin-left: auto; }

.composer {
  background: linear-gradient(180deg, rgba(30, 41, 62, .85), rgba(17, 24, 39, .85));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  background: #0c1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s;
}
.composer textarea:focus { border-color: var(--accent); }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.composer-left, .composer-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.checkbox { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13.5px; cursor: pointer; user-select: none; }
.checkbox input { accent-color: var(--accent); width: 15px; height: 15px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.hint {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  background: var(--accent-soft);
  border: 1px solid rgba(79, 140, 255, .3);
}
.hint.error { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .35); color: #ffc0c0; }

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.tab.active { color: var(--text); background: var(--accent-soft); border-color: rgba(79, 140, 255, .35); }
.count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .08);
  font-size: 11.5px;
  text-align: center;
}

.tabs-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.tasks { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card.status-failed { border-color: rgba(255, 107, 107, .35); }
.card.status-done { border-color: rgba(53, 208, 127, .3); }

.card-head { display: flex; gap: 12px; align-items: flex-start; }

.thumb {
  width: 86px; height: 86px;
  flex: 0 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #0c1220 center/cover no-repeat;
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-main { flex: 1; min-width: 0; }
.card-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: #a9c8ff;
}
.badge.douyin { background: rgba(255, 70, 110, .14); color: #ff8fa8; }
.badge.xiaohongshu { background: rgba(255, 45, 85, .14); color: #ff8098; }
.badge.kuaishou { background: rgba(255, 145, 0, .14); color: #ffbe66; }
.badge.weibo { background: rgba(255, 190, 60, .14); color: #ffd166; }
.badge.instagram { background: rgba(200, 80, 200, .16); color: #e79ae7; }
.badge.unknown { background: rgba(255, 255, 255, .07); color: var(--muted); }

.status {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
}
.status.parsing, .status.queued { color: #9dc0ff; background: rgba(79, 140, 255, .12); }
.status.downloading { color: #ffd28a; background: rgba(245, 181, 68, .12); }
.status.ready { color: #8fe5b6; background: rgba(53, 208, 127, .12); }
.status.done { color: #8fe5b6; background: rgba(53, 208, 127, .16); }
.status.failed { color: #ff9d9d; background: rgba(255, 107, 107, .14); }

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.progress {
  margin-top: 11px;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #4f8cff, #7a5cff);
  transition: width .3s ease;
}
.progress-bar.failed { background: linear-gradient(90deg, #ff6b6b, #ff8f6b); }
.progress-bar.done { background: linear-gradient(90deg, #35d07f, #4fd1c5); }
.progress-text { margin-top: 6px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }

.error-box {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(255, 107, 107, .1);
  border: 1px solid rgba(255, 107, 107, .3);
  color: #ffc0c0;
  font-size: 13px;
  word-break: break-word;
}
.warn-box {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--warn);
  word-break: break-word;
}

.media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.media-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #0c1220 center/cover no-repeat;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .tag {
  position: absolute;
  left: 6px; bottom: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .6);
  font-size: 11px;
  color: #dbe6ff;
}
.media-item .tag.live { background: rgba(255, 45, 85, .75); color: #fff; }

.files { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .size { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.file-row a { color: #9dc0ff; text-decoration: none; font-size: 13px; white-space: nowrap; }
.file-row a:hover { text-decoration: underline; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty p { margin: 6px 0; }

.modal {
  position: fixed; inset: 0;
  background: rgba(4, 8, 16, .72);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 40;
}
.modal.hidden, .lightbox.hidden, .hint[hidden], .toast[hidden] { display: none; }
.modal-box {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 17px; }

.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  background: #0c1220;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }

.cookie-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.cookie-card { border: 1px solid var(--border-soft); border-radius: 11px; padding: 12px; background: var(--card); }
.cookie-card h3 { margin: 0 0 4px; font-size: 14.5px; display: flex; align-items: center; justify-content: space-between; }
.cookie-card .status-text { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.cookie-card .status-text.on { color: var(--success); }
.cookie-card .row { display: flex; gap: 8px; margin-top: 8px; }
.cookie-card textarea { min-height: 68px; font-size: 12.5px; }

.cookie-check {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  word-break: break-word;
}
.cookie-check.ok { background: rgba(53, 208, 127, .1); border-color: rgba(53, 208, 127, .35); color: #8fe5b6; }
.cookie-check.bad { background: rgba(255, 107, 107, .1); border-color: rgba(255, 107, 107, .3); color: #ffc0c0; }

.token-create { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.token-create input { flex: 1; min-width: 180px; }
.token-create select {
  background: #0c1220;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 10px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}
.token-list { display: flex; flex-direction: column; gap: 6px; }
.token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  flex-wrap: wrap;
}
.token-row .token-name { font-weight: 600; }
.token-row code { color: #9dc0ff; font-size: 12.5px; }
.token-row .token-meta { color: var(--muted); font-size: 12px; margin-left: auto; }
.token-new {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(53, 208, 127, .1);
  border: 1px solid rgba(53, 208, 127, .35);
}
.token-new-title { font-size: 12.5px; color: #8fe5b6; margin-bottom: 6px; }
.token-new-value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.token-new-value code { word-break: break-all; font-size: 12.5px; }
.token-usage { margin-top: 12px; font-size: 13px; color: var(--muted); }
.token-usage summary { cursor: pointer; }
.token-usage pre {
  background: #0c1220;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12.5px;
  color: #cbd8f0;
}
.token-usage code { color: #9dc0ff; }

.meta-note {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  background: rgba(79, 140, 255, .08);
  border: 1px solid rgba(79, 140, 255, .25);
  color: #a9c8ff;
  font-size: 12.5px;
  word-break: break-all;
}

.lightbox {
  position: fixed; inset: 0;
  background: rgba(3, 6, 12, .9);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 40px 20px;
}
.lightbox-body { max-width: 92vw; max-height: 88vh; display: grid; place-items: center; gap: 12px; }
.lightbox-body img, .lightbox-body video { max-width: 92vw; max-height: 78vh; border-radius: 10px; }
.steps-box {
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(79, 140, 255, .07);
  border: 1px solid rgba(79, 140, 255, .25);
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  font-size: 13.5px;
  color: #dbe6ff;
}
.step { line-height: 1.5; }
.step-alt { color: var(--muted); font-size: 12.5px; }

.save-message {
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 13.5px;
  word-break: break-word;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border-soft);
  color: var(--text);
}
.save-message.ok { background: rgba(53, 208, 127, .1); border-color: rgba(53, 208, 127, .35); color: #a5ecc9; }
.save-message.bad { background: rgba(245, 181, 68, .12); border-color: rgba(245, 181, 68, .45); color: #ffdca0; }

.lightbox-body .caption { color: var(--muted); font-size: 13px; text-align: center; }
.lightbox-body .actions { display: flex; gap: 10px; }
.lightbox-close {
  position: absolute; top: 14px; right: 18px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #1b2436;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
  font-size: 13.5px;
  max-width: 90vw;
}
.toast.error { border-color: rgba(255, 107, 107, .4); color: #ffc0c0; }

@media (max-width: 640px) {
  .app { padding: 16px 12px 70px; }
  .brand-text h1 { font-size: 16px; }
  .thumb { width: 68px; height: 68px; }
  .topbar { flex-wrap: wrap; }
  .composer-actions { flex-direction: column; align-items: stretch; }
  .composer-right { justify-content: flex-end; }
  .media { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
}
