:root {
  --bg: #0b0f1a;
  --bg-soft: #111726;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf4;
  --muted: #8b94a7;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px 380px at 12% -5%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(700px 420px at 95% 0%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(800px 500px at 50% 110%, rgba(124, 92, 255, 0.12), transparent 60%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 22px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo { width: 42px; height: 42px; color: var(--accent-2); }
.brand h1 { font-size: 22px; letter-spacing: .5px; }
.brand p { color: var(--muted); font-size: 13px; }

.health-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--card-border);
  font-size: 13px; color: var(--muted);
}
.health-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.health-badge[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.health-badge[data-state="ok"] { color: var(--text); }
.health-badge[data-state="warn"] .dot { background: #fbbf24; box-shadow: 0 0 10px #fbbf24; }
.health-badge[data-state="warn"] { color: #fde68a; }

/* ---------- 主体 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 18px 22px 40px; }

/* 标签页 */
.tabs {
  display: flex; gap: 10px; margin: 14px 0 22px;
  border-bottom: 1px solid var(--card-border); padding-bottom: 0;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; cursor: pointer;
  background: transparent; border: none; color: var(--muted);
  font-size: 15px; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .2s, border-color .2s;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(8px);
}
.input-card h2 { font-size: 18px; margin-bottom: 6px; }
.input-card .muted { margin-bottom: 18px; }
code {
  background: rgba(124, 92, 255, 0.14);
  color: #c4b5fd; padding: 1px 7px; border-radius: 6px; font-size: .9em;
}

/* 输入行 */
.input-row { display: flex; gap: 12px; }
.input-row input {
  flex: 1; min-width: 0;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 12px; color: var(--text); font-size: 15px;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.input-row input::placeholder { color: #5b6478; }
.input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px;
  border: 1px solid var(--card-border); background: rgba(255,255,255,0.06);
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .2s, border-color .2s, box-shadow .2s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #5b8cff);
  border: none; box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
}
.btn.primary:hover { box-shadow: 0 10px 30px rgba(124, 92, 255, 0.5); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.copied { border-color: var(--ok); color: var(--ok); }

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

/* 示例标签 */
.chips { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px; color: var(--muted);
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.04); border: 1px dashed var(--card-border);
  cursor: pointer; transition: color .2s, border-color .2s;
}
.chip:hover { color: var(--accent-2); border-color: var(--accent-2); }

/* ---------- 结果区 ---------- */
.results { margin-top: 24px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.section-head h3 { font-size: 16px; }
.section-head .sub { color: var(--muted); font-size: 13px; }

/* 手机端保存提示：仅在触摸设备上显示 */
.save-hint { display: none; font-size: 12.5px; color: #9aa3b8; margin-bottom: 14px; }
@media (pointer: coarse) {
  .save-hint { display: block; }
}

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

.video-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .15s, border-color .2s;
}
.video-card:hover { transform: translateY(-3px); border-color: rgba(124,92,255,.5); }

.video-cover { position: relative; aspect-ratio: 16/9; background: #0e1322; overflow: hidden; }
.video-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-cover .dur {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 12px;
  padding: 3px 8px; border-radius: 7px;
}
.badge {
  position: absolute; left: 10px; top: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 999px;
}
.badge.def {
  background: linear-gradient(135deg, var(--accent), #5b8cff); color: #fff;
}
.badge.q { background: rgba(0,0,0,.7); color: #fbbf24; top: auto; bottom: 10px; left: 10px; }

.video-meta { padding: 14px 16px; }
.video-meta .row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 4px 0; color: var(--muted);
}
.video-meta .row b { color: var(--text); font-weight: 600; }
.video-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.video-actions .btn { flex: 1; }

/* 图片卡片：图片与操作按钮分离，长按图片直接呼出系统保存菜单 */
.image-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; overflow: hidden;
  transition: transform .15s, border-color .2s;
}
.image-card:hover { transform: translateY(-3px); border-color: rgba(124,92,255,.5); }
.image-cell {
  aspect-ratio: 1/1; overflow: hidden; background: #0e1322;
  cursor: zoom-in; touch-action: manipulation;
}
.image-cell img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .25s;
}
.image-card:hover .image-cell img { transform: scale(1.05); }
.image-actions { display: flex; gap: 8px; padding: 10px; }
.image-actions .btn { flex: 1; }

/* 空状态 / 错误 */
.empty {
  text-align: center; color: var(--muted); padding: 46px 20px;
  background: var(--card); border: 1px dashed var(--card-border); border-radius: var(--radius);
}
.empty svg { width: 44px; height: 44px; opacity: .5; margin-bottom: 10px; }
.error-box {
  background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.3);
  color: #fca5a5; padding: 14px 18px; border-radius: 12px; font-size: 14px;
}

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 30px; }
.modal[hidden],
.toast[hidden] { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,7,14,.78); backdrop-filter: blur(4px); }
.modal-body {
  position: relative; max-width: min(1000px, 94vw); max-height: 92vh;
  background: var(--bg-soft); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0,0,0,.55); color: #fff; font-size: 22px; line-height: 1;
}
.modal-close:hover { background: rgba(0,0,0,.8); }
#modal-content video { max-width: 100%; max-height: 80vh; display: block; background: #000; }
#modal-content img { max-width: 100%; max-height: 80vh; display: block; object-fit: contain; }
.modal-tools { display: flex; gap: 10px; padding: 14px; justify-content: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #1a2132; border: 1px solid var(--card-border); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 200; max-width: 86vw;
  animation: rise .25s ease;
}
.toast.error { border-color: rgba(248,113,113,.5); color: #fca5a5; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.foot {
  margin-top: 34px; text-align: center; color: #525c70; font-size: 12.5px;
}

@media (max-width: 640px) {
  .input-row { flex-direction: column; }
  .video-grid { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .topbar { padding-top: 18px; }
}
