/* ==========================================================================
   自媒体下载平台 - 样式表
   设计令牌集中在 :root，改主题只需要动这里
   ========================================================================== */

:root {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eef0f7;
  --sidebar-bg: #12141c;
  --sidebar-fg: #a8adbd;
  --sidebar-fg-strong: #ffffff;

  --fg: #1a1d29;
  --fg-muted: #666c80;
  --fg-subtle: #8b90a3;

  --border: #e3e6ef;
  --border-strong: #d0d4e2;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-fg: #ffffff;

  --success: #0d9668;
  --success-soft: #e7f6f0;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdeced;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 40, .06);
  --shadow: 0 4px 16px rgba(16, 20, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 20, 40, .12);

  --sidebar-w: 264px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system,
          BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1017;
    --bg-elevated: #171a24;
    --bg-sunken: #1e2130;
    --sidebar-bg: #0a0c12;

    --fg: #e8eaf2;
    --fg-muted: #9aa0b4;
    --fg-subtle: #6f7488;

    --border: #262a38;
    --border-strong: #333849;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-soft: #1e2140;

    --success: #34d399;
    --success-soft: #10291f;
    --warn: #fbbf24;
    --warn-soft: #2b2010;
    --danger: #f87171;
    --danger-soft: #2d1618;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

/* display: flex/grid 会盖掉浏览器对 [hidden] 的默认样式，这里补回来 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ============================ 布局 ============================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============================ 侧边栏 ============================ */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(99, 102, 241, .4);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { color: var(--sidebar-fg-strong); font-size: 15px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: #6b7186; letter-spacing: .6px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-fg);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.is-active { background: rgba(99, 102, 241, .18); color: #fff; }
.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 0 6px;
}

.panel-title {
  margin: 22px 6px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #5b6076;
  font-weight: 600;
}

.credentials-panel { margin: 0; padding: 0; border: 0; }
.credentials-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.credentials-summary::-webkit-details-marker { display: none; }
.credentials-summary::after {
  content: "⌄";
  color: #6b7186;
  font-size: 15px;
  line-height: 1;
  transition: transform .18s ease;
}
.credentials-panel:not([open]) .credentials-summary::after { transform: rotate(-90deg); }
.credentials-summary-note { display: none; }

.platform-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.platform-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.platform-list .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #3f4457; flex-shrink: 0;
}
.platform-list .dot.on { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.platform-list .dot.warn { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .16); }
.platform-list .hint { margin-left: auto; font-size: 10px; color: #6b7186; }

/* Cookie 导入 */
.cookie-box { padding: 0 6px; display: flex; flex-direction: column; gap: 8px; }
.cookie-hint { margin: 0; font-size: 11px; line-height: 1.6; color: #6b7186; }

.cookie-select {
  width: 100%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #d5d8e3;
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.cookie-select:focus { border-color: var(--accent); }
.cookie-select option { background: #1b1e29; color: #d5d8e3; }

.cookie-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cookie-btn {
  flex: 1;
  min-width: 62px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #b9bdcc;
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  font-size: 11.5px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cookie-btn:hover:not(:disabled) { background: rgba(99, 102, 241, .25); color: #fff; }
.cookie-btn:disabled { opacity: .5; cursor: not-allowed; }
.cookie-btn-wide { flex: none; width: 100%; }
.cookie-btn-primary {
  background: rgba(99, 102, 241, .28);
  border-color: rgba(99, 102, 241, .45);
  color: #c7cbff;
  font-weight: 500;
}
.cookie-btn-primary:hover:not(:disabled) { background: rgba(99, 102, 241, .45); color: #fff; }

.detect-results {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  background: rgba(0, 0, 0, .22);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}
.detect-row { display: flex; align-items: baseline; gap: 6px; line-height: 1.5; }
.detect-row .mark { flex-shrink: 0; width: 11px; }
.detect-row.ok { color: #34d399; }
.detect-row.no { color: #6b7186; }
.detect-row .who { font-weight: 600; }
.detect-row .why { color: inherit; opacity: .8; }

.cookie-divider { height: 1px; background: rgba(255, 255, 255, .08); margin: 4px 0; }

.cookie-hint a { color: #8b93f8; }

.cookie-steps {
  margin: 0;
  padding-left: 17px;
  font-size: 11px;
  line-height: 1.75;
  color: #8a90a5;
}
.cookie-steps li { margin-bottom: 3px; }
.cookie-steps b { color: #b9bdcc; }
.cookie-steps .alt {
  display: block;
  color: #6b7186;
  font-size: 10px;
  line-height: 1.55;
  margin-top: 1px;
}
.cookie-steps .alt b { color: #8a90a5; font-weight: 600; }
.cookie-steps a { color: #8b93f8; }
.cookie-steps code {
  background: rgba(255, 255, 255, .08);
  padding: 0 3px;
  border-radius: 3px;
  font-size: 10px;
}
.cookie-hint code {
  background: rgba(255, 255, 255, .08);
  padding: 0 3px;
  border-radius: 3px;
  font-size: 10px;
}

.cookie-input {
  width: 100%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #d5d8e3;
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 11px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  resize: vertical;
  outline: none;
}
.cookie-input:focus { border-color: var(--accent); }
.cookie-input::placeholder { color: #5b6076; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.env-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; padding: 0 6px; }
.env-row .path {
  font-weight: 400;
  color: #7d8298;
  font-size: 11px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
}

/* ---- 环境自检 ---- */
.diag-link {
  width: 100%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #b9bdcc;
  border-radius: var(--radius-sm);
  padding: 7px 6px;
  font-size: 11.5px;
  cursor: pointer;
  margin-bottom: 10px;
}
.diag-link:hover { background: rgba(99, 102, 241, .25); color: #fff; }

.diag-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 200;
}
.diag-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.diag-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 0 4px;
}
.diag-body { padding: 12px 16px; overflow-y: auto; font-size: 12.5px; }
.diag-foot { padding: 10px 16px; border-top: 1px solid var(--border); text-align: right; }

.diag-group { margin-bottom: 14px; }
.diag-group h4 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: .5px;
  color: var(--fg-subtle);
  text-transform: uppercase;
}
.diag-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
  line-height: 1.5;
}
.diag-item:last-child { border-bottom: 0; }
.diag-item .k { color: var(--fg-muted); flex: 0 0 42%; }
.diag-item .v { font-weight: 600; word-break: break-all; }
.diag-item.ok .v { color: var(--success); }
.diag-item.bad .v { color: var(--danger); }
.diag-verdict {
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.diag-verdict.ok { background: var(--success-soft); color: var(--success); }
.diag-verdict.bad { background: var(--warn-soft); color: var(--warn); }

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.chip-ok { background: rgba(52, 211, 153, .16); color: #34d399; }
.chip-warn { background: rgba(251, 191, 36, .16); color: #fbbf24; }

/* ============================ 主区 ============================ */
.main { padding: 34px 40px 60px; max-width: 1180px; width: 100%; }

.view { display: none; }
.view.is-active { display: block; animation: fade .25s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 22px; }
.view-head h1 { margin: 0 0 5px; font-size: 25px; letter-spacing: -.3px; }
.view-head p { margin: 0; color: var(--fg-muted); font-size: 13.5px; }

/* ============================ 输入区 ============================ */
.composer {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

#linkInput {
  width: 100%;
  border: 0;
  outline: none;
  resize: vertical;
  min-height: 108px;
  padding: 18px 20px;
  background: transparent;
  font-size: 14px;
  line-height: 1.7;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
#linkInput::placeholder { color: var(--fg-subtle); font-family: var(--font); }

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  flex-wrap: wrap;
}
.composer-actions { display: flex; gap: 8px; margin-left: auto; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 21px; border-radius: 20px;
  background: var(--border-strong);
  position: relative; transition: background .2s; flex-shrink: 0;
}
.switch-dot {
  position: absolute; top: 2.5px; left: 2.5px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-dot { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch-label { font-size: 13px; color: var(--fg-muted); }

/* ============================ 按钮 ============================ */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--fg-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-elevated); color: var(--fg); }

.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover:not(:disabled) { background: var(--accent); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* iOS：文件已就绪、等用户点一下存进相册 */
.btn-share-ready {
  background: var(--success) !important;
  color: #fff !important;
  animation: share-pulse 1.6s ease-in-out infinite;
}
@keyframes share-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--success) 0%, transparent); }
}
.btn-danger { background: transparent; border-color: var(--border-strong); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn.is-loading .btn-text { opacity: .6; }

/* ============================ 提示条 ============================ */
.alert-area { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.alert {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  align-items: flex-start;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert strong { font-weight: 600; }
.alert .alert-url {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  opacity: .75;
  word-break: break-all;
  display: block;
  margin-top: 2px;
}

/* ============================ 解析结果 ============================ */
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}
.results-head h2 { margin: 0; font-size: 16px; }
.results-head em {
  font-style: normal;
  background: var(--bg-sunken);
  color: var(--fg-muted);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
  margin-left: 4px;
}

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

.card {
  display: flex;
  gap: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, border-color .18s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }

.card-cover {
  width: 132px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunken);
  flex-shrink: 0;
  position: relative;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-cover .duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.card-cover .cover-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--fg-subtle); font-size: 11px;
}

.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.card-tags { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  letter-spacing: .2px;
}
.tag-douyin { background: #1a1a1a; color: #fff; }
.tag-wxchannels { background: #07c160; color: #fff; }
.tag-type { background: var(--bg-sunken); color: var(--fg-muted); }

.card-title {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
  font-size: 12.5px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.card-meta .avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: var(--bg-sunken); }
.card-meta .sep { color: var(--border-strong); }

.card-stats { display: flex; gap: 16px; color: var(--fg-subtle); font-size: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-stats b { color: var(--fg-muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.card-actions { margin-top: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  background: var(--bg-elevated);
  font-size: 12.5px;
  cursor: pointer;
  max-width: 260px;
  outline: none;
}
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.card-note {
  font-size: 11.5px;
  color: var(--fg-subtle);
  width: 100%;
  margin-top: 2px;
}

/* ============================ 任务队列 ============================ */
.tasks-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.stat-row { display: flex; gap: 18px; font-size: 13px; color: var(--fg-muted); flex-wrap: wrap; }
.stat-row b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

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

.task {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
}

.task-head { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.task-thumb { width: 42px; height: 42px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-sunken); flex-shrink: 0; }
.task-info { flex: 1; min-width: 0; }
.task-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-sub { font-size: 11.5px; color: var(--fg-subtle); display: flex; gap: 8px; flex-wrap: wrap; }
.task-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.status-pending { background: var(--bg-sunken); color: var(--fg-muted); }
.status-downloading, .status-merging { background: var(--accent-soft); color: var(--accent); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-failed { background: var(--danger-soft); color: var(--danger); }
.status-canceled { background: var(--bg-sunken); color: var(--fg-subtle); }

.progress {
  height: 6px;
  border-radius: 6px;
  background: var(--bg-sunken);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  border-radius: 6px;
  transition: width .3s ease;
}
.progress-fill.done { background: var(--success); }
.progress-fill.fail { background: var(--danger); }

.task.is-active .progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.task-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--fg-subtle);
  gap: 10px;
  flex-wrap: wrap;
}
.task-msg { font-size: 11.5px; margin-top: 7px; padding: 7px 10px; border-radius: var(--radius-sm); }
.task-msg.err { background: var(--danger-soft); color: var(--danger); }
.task-msg.warn { background: var(--warn-soft); color: var(--warn); }

/* ============================ 空状态 ============================ */
.empty { text-align: center; padding: 60px 20px; color: var(--fg-subtle); }
.empty-art {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  display: grid; place-items: center;
  color: var(--fg-subtle);
}
.empty-art svg { width: 28px; height: 28px; }
.empty p { margin: 0 0 4px; font-size: 14px; color: var(--fg-muted); font-weight: 500; }
.empty span { font-size: 12.5px; }

/* ============================ Toast ============================ */
.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 340px;
  animation: slide-in .22s ease;
  pointer-events: auto;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.is-leaving { animation: slide-out .22s ease forwards; }

@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes slide-out { to { opacity: 0; transform: translateX(24px); } }

/* ============================ 响应式 ============================ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    z-index: 20;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 18px;
    overflow: visible;
    box-shadow: 0 5px 18px rgba(0, 0, 0, .16);
  }
  .brand { padding: 0; }
  .nav { flex-direction: row; margin-left: auto; }
  .nav-item { min-height: 44px; }
  .support-panel, .sidebar-foot { display: none; }
  .credentials-panel {
    order: 3;
    flex-basis: 100%;
    width: 100%;
  }
  .credentials-summary {
    margin: 0;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .06);
    color: #b9bdcc;
    letter-spacing: .4px;
  }
  .credentials-summary-note {
    display: inline;
    margin-left: auto;
    margin-right: 8px;
    color: #7d8298;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
  }
  .credentials-panel[open] {
    padding: 8px 10px 12px;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, .14);
  }
  .credentials-panel[open] .credentials-summary { background: transparent; }
  .credentials-panel[open] .cookie-box { padding-top: 8px; }
  .credentials-panel .cookie-btn,
  .credentials-panel .cookie-select { min-height: 44px; }
  .switch { min-height: 44px; }
  .main { padding: 22px 18px 50px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .sidebar { padding: 10px 12px; }
  .brand { flex: 1; min-width: 0; gap: 9px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-text strong { font-size: 14px; }
  .brand-text span { display: none; }
  .nav { order: 2; width: 100%; margin-left: 0; gap: 6px; }
  .nav-item {
    flex: 1;
    justify-content: center;
    min-height: 44px;
    padding: 9px 10px;
    text-align: center;
  }
  .main { padding: 18px 12px calc(32px + env(safe-area-inset-bottom)); }
  .view-head { margin-bottom: 16px; }
  .view-head h1 { font-size: 21px; line-height: 1.35; }
  .view-head p { font-size: 13px; line-height: 1.6; }
  #linkInput { min-height: 122px; padding: 14px; font-size: 14px; }
  .composer-bar { flex-direction: column; align-items: stretch; }
  .switch { align-items: flex-start; min-height: 30px; }
  .switch-label { font-size: 12.5px; line-height: 1.45; }
  .composer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-left: 0;
  }
  .btn { justify-content: center; min-height: 44px; }
  #parseBtn { grid-column: 1 / -1; }
  .results-head { margin: 22px 0 12px; }
  .results-head .btn { min-height: 40px; padding-inline: 12px; }
  .card { flex-direction: column; gap: 12px; padding: 12px; }
  .card-cover { width: 100%; aspect-ratio: 16 / 9; }
  .card-title { font-size: 15px; }
  .card-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .select, .card-actions .btn { width: 100%; max-width: none; min-height: 44px; }
  .card-stats { gap: 10px 14px; margin-bottom: 10px; }
  .tasks-bar { align-items: stretch; }
  .tasks-bar > .btn { width: 100%; }
  .task { padding: 12px; }
  .task-head { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; }
  .task-side { grid-column: 1 / -1; justify-content: space-between; }
  .task-side .btn { flex: 1; }
  .task-foot { gap: 5px; align-items: flex-start; flex-direction: column; }
  .empty { padding: 44px 14px; }
  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .toast { max-width: none; padding: 11px 13px; }
}

@media (max-width: 380px) {
  .nav-item { padding-inline: 7px; gap: 7px; font-size: 12.5px; }
  .nav-item svg { width: 16px; height: 16px; }
  .credentials-summary { padding-inline: 10px; }
  .results-head { align-items: flex-start; gap: 10px; flex-direction: column; }
  .results-head .btn { width: 100%; }
}

/* ====================== Mobile visual refinement ====================== */
@media (max-width: 620px) {
  body {
    background:
      radial-gradient(circle at 90% 0, rgba(112, 84, 255, .16), transparent 32%),
      radial-gradient(circle at 0 40%, rgba(72, 196, 255, .10), transparent 28%),
      var(--bg);
  }

  .sidebar {
    gap: 9px;
    padding: 12px;
    background:
      radial-gradient(circle at 100% 0, rgba(137, 101, 255, .34), transparent 48%),
      linear-gradient(135deg, #111625 0%, #161735 48%, #252050 100%);
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    box-shadow: 0 10px 26px rgba(17, 21, 42, .22);
  }

  .brand-mark {
    background: linear-gradient(135deg, #8b5cf6, #4f46e5 58%, #38bdf8);
    box-shadow: 0 7px 18px rgba(96, 74, 230, .45);
  }

  .brand-text strong { letter-spacing: .1px; }

  .nav-item {
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .055);
    color: #c9cee7;
  }
  .nav-item.is-active {
    border-color: rgba(167, 139, 250, .38);
    background: linear-gradient(135deg, rgba(117, 83, 245, .42), rgba(74, 77, 208, .34));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 6px 14px rgba(31, 23, 91, .22);
  }

  .credentials-summary {
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(8, 11, 26, .32);
    color: #d9ddf2;
  }
  .credentials-panel[open] {
    background: rgba(8, 11, 26, .44);
    border-color: rgba(167, 139, 250, .24);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  }

  .main {
    min-height: calc(100vh - 148px);
    background:
      linear-gradient(180deg, rgba(245, 247, 255, .72), transparent 300px),
      transparent;
  }

  .view-head {
    position: relative;
    overflow: hidden;
    margin: 0;
    padding: 19px 18px 48px;
    border: 1px solid rgba(116, 93, 238, .25);
    border-radius: 20px 20px 15px 15px;
    background:
      radial-gradient(circle at 96% 6%, rgba(255, 255, 255, .28), transparent 30%),
      linear-gradient(135deg, #35266f, #5140b9 55%, #4065d5);
    box-shadow: 0 13px 28px rgba(79, 70, 229, .18);
  }
  .view-head::after {
    content: "";
    position: absolute;
    right: -17px;
    bottom: -35px;
    width: 112px;
    height: 112px;
    border: 18px solid rgba(255, 255, 255, .10);
    border-radius: 50%;
  }
  .view-head h1 {
    position: relative;
    z-index: 1;
    margin-bottom: 4px;
    color: #fff;
    letter-spacing: -.45px;
  }
  .view-head p {
    position: relative;
    z-index: 1;
    color: rgba(241, 244, 255, .82);
  }

  .composer {
    position: relative;
    z-index: 2;
    margin-top: -30px;
    border-color: color-mix(in srgb, var(--accent) 16%, var(--border));
    border-radius: 17px;
    box-shadow: 0 14px 30px rgba(32, 40, 82, .13), 0 1px 1px rgba(30, 36, 70, .07);
  }
  .composer:focus-within {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), 0 16px 34px rgba(32, 40, 82, .16);
  }
  #linkInput { min-height: 132px; line-height: 1.75; }
  .composer-bar {
    padding: 12px;
    gap: 12px;
    background: color-mix(in srgb, var(--accent-soft) 42%, var(--bg-elevated));
  }
  .switch {
    min-height: 44px;
    padding: 3px 2px;
    border-radius: 10px;
  }
  .switch-track { box-shadow: inset 0 0 0 1px rgba(26, 29, 41, .08); }
  .btn { border-radius: 10px; font-weight: 600; }
  .btn-ghost {
    background: var(--bg-elevated);
    border-color: color-mix(in srgb, var(--border-strong) 78%, var(--accent));
  }
  .btn-primary {
    background: linear-gradient(135deg, #6d4aff, #4f46e5 56%, #3567e6);
    box-shadow: 0 8px 16px rgba(79, 70, 229, .28);
  }
  .btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #7b5bff, #5a51ee 56%, #4374ed); }

  .results-head { margin-top: 26px; }
  .card, .task {
    border-color: color-mix(in srgb, var(--border) 82%, var(--accent));
    box-shadow: 0 9px 22px rgba(32, 40, 82, .07);
  }
  .empty {
    margin-top: 20px;
    padding: 36px 16px;
    border: 1px dashed color-mix(in srgb, var(--accent) 23%, var(--border));
    border-radius: 18px;
    background: color-mix(in srgb, var(--bg-elevated) 82%, var(--accent-soft));
  }
  .empty-art {
    background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 45%, var(--bg-elevated)));
    color: var(--accent);
  }
  .toast { border-radius: 14px; box-shadow: 0 12px 28px rgba(21, 24, 48, .18); }
}

@media (prefers-color-scheme: dark) and (max-width: 620px) {
  .main { background: linear-gradient(180deg, rgba(44, 43, 98, .34), transparent 300px); }
  .view-head { box-shadow: 0 14px 30px rgba(0, 0, 0, .34); }
  .composer { box-shadow: 0 14px 30px rgba(0, 0, 0, .26); }
}
