:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1a1b1e;
  --text-2: #5a5c63;
  --border: #e4e6ea;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: #dbeafe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #181b21;
  --surface-2: #22262e;
  --text: #e7e9ee;
  --text-2: #9aa0aa;
  --border: #2c313a;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-soft: #1e3a5f;
  --green: #4ade80;
  --green-soft: #14532d;
  --orange: #fb923c;
  --orange-soft: #431407;
  --purple: #a78bfa;
  --purple-soft: #2e1065;
  --red: #f87171;
  --red-soft: #450a0a;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 13px;
}
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  font-size: 17px; color: var(--text);
}
.icon-btn:hover { border-color: var(--primary); }

.hero { padding: 48px 0 24px; text-align: center; }
.hero h1 { font-size: 28px; margin: 0 0 10px; letter-spacing: -.5px; }
.hero .sub { color: var(--text-2); margin: 0 auto 24px; max-width: 560px; }

.parse-form { display: flex; gap: 10px; max-width: 640px; margin: 0 auto; }
.parse-form input {
  flex: 1; padding: 13px 16px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s;
}
.parse-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn {
  padding: 13px 22px; font-size: 15px; font-weight: 600;
  border: none; border-radius: 12px; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.sm { padding: 8px 14px; font-size: 13px; }

.msg { max-width: 640px; margin: 16px auto 0; padding: 12px 16px; border-radius: 10px; font-size: 14px; }
.msg.error { background: var(--red-soft); color: var(--red); border: 1px solid var(--red); }

.result { padding: 16px 0 48px; }
.empty { text-align: center; padding: 56px 0; color: var(--text-2); }
.empty-icon { font-size: 40px; margin-bottom: 8px; }

.video-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 16px;
}
.video-head { display: flex; gap: 14px; padding: 16px; }
.video-head img {
  width: 96px; height: 64px; object-fit: cover; border-radius: 8px;
  background: var(--surface-2); flex-shrink: 0;
}
.video-meta { min-width: 0; }
.video-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; word-break: break-word; }
.video-info { font-size: 13px; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.tag.missav { background: var(--purple-soft); color: var(--purple); }
.tag.generic { background: var(--surface-2); color: var(--text-2); }

.source-list { border-top: 1px solid var(--border); }
.source-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.source-row:last-child { border-bottom: none; }
.fmt {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; padding: 3px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 700;
}
.fmt.m3u8 { background: var(--orange-soft); color: var(--orange); }
.fmt.mp4 { background: var(--green-soft); color: var(--green); }
.fmt.flv, .fmt.ts, .fmt.webm, .fmt.mkv { background: var(--purple-soft); color: var(--purple); }
.source-quality { font-size: 14px; color: var(--text); font-weight: 500; }
.source-domain { font-size: 12px; color: var(--text-2); word-break: break-all; }
.source-actions { margin-left: auto; display: flex; gap: 8px; }

.export-all { display: flex; justify-content: center; margin-top: 8px; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer { padding: 24px 16px 40px; color: var(--text-2); font-size: 12px; text-align: center; }

@media (max-width: 560px) {
  .hero { padding: 32px 0 16px; }
  .hero h1 { font-size: 22px; }
  .parse-form { flex-direction: column; }
  .source-actions { margin-left: 0; width: 100%; }
  .video-head img { width: 72px; height: 48px; }
}
