:root {
  --bg: #0e1116;
  --bg-elevated: #151a21;
  --bg-soft: #1b222b;
  --border: #242d38;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(1200px 600px at 20% -10%, rgba(79, 140, 255, 0.12), transparent), var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: rgba(14, 17, 22, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand { font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }

.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--accent-soft); }

.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; flex: 1; }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 20px; border-top: 1px solid var(--border); }

h1, h2, h3 { line-height: 1.3; margin: 0 0 12px; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; }

.grid { display: grid; gap: 18px; }
.grid.media-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.media-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.media-card:hover { transform: translateY(-2px); border-color: #33404f; }
.media-card a { color: inherit; text-decoration: none; display: block; }
.thumb {
  aspect-ratio: 16 / 9;
  background: #10151b url("/static/placeholder.svg") center / 20% no-repeat;
  background-size: cover;
  border-bottom: 1px solid var(--border);
}
.media-body { padding: 12px 14px 14px; }
.media-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.status-ready { color: var(--success); border-color: rgba(63, 185, 80, 0.4); background: rgba(63, 185, 80, 0.1); }
.badge.status-failed { color: var(--danger); border-color: rgba(248, 81, 73, 0.4); background: rgba(248, 81, 73, 0.1); }
.badge.status-cancelled { color: var(--muted); }
.badge.status-queued { color: var(--warning); border-color: rgba(210, 153, 34, 0.4); background: rgba(210, 153, 34, 0.1); }
.badge.status-downloading, .badge.status-processing, .badge.status-uploading { color: var(--accent); border-color: rgba(79, 140, 255, 0.4); background: var(--accent-soft); }
.badge.role { color: var(--accent); border-color: rgba(79, 140, 255, 0.4); }

.thumb { aspect-ratio: 16 / 9; background: #10151b; overflow: hidden; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img.broken { display: none; }
.thumb .placeholder { color: #33404f; font-size: 26px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: #222b36; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #6d9dff; }
.btn.danger { color: var(--danger); border-color: rgba(248, 81, 73, 0.45); background: rgba(248, 81, 73, 0.08); }
.btn.danger:hover { background: rgba(248, 81, 73, 0.16); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.link { border: none; background: none; color: var(--accent); padding: 0; font-size: 14px; }
.btn.link:hover { background: none; text-decoration: underline; }

button.link { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 14px; font-family: var(--font); }
button.link:hover { text-decoration: underline; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.inline { display: inline; }

form.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filters input[type="search"] { max-width: 280px; }
.filters select { max-width: 160px; }

.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; border: 1px solid var(--border); background: var(--bg-soft); }
.alert.success { border-color: rgba(63, 185, 80, 0.4); background: rgba(63, 185, 80, 0.08); color: #9ae6a6; }
.alert.error { border-color: rgba(248, 81, 73, 0.4); background: rgba(248, 81, 73, 0.08); color: #ffb3ae; }
.alert.warning { border-color: rgba(210, 153, 34, 0.4); background: rgba(210, 153, 34, 0.08); color: #f0c674; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; text-transform: none; white-space: nowrap; background: var(--bg-soft); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
td.actions { white-space: nowrap; }
td .btn + .btn { margin-left: 6px; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 22px; color: var(--muted); font-size: 14px; }
.pagination a, .pagination span { padding: 5px 10px; border-radius: 7px; border: 1px solid var(--border); }
.pagination a:hover { background: var(--bg-soft); text-decoration: none; }
.pagination .current { background: var(--accent-soft); border-color: rgba(79, 140, 255, 0.4); color: var(--text); }

.auth-shell { max-width: 420px; margin: 7vh auto 0; }
.auth-shell .card { padding: 28px; }
.auth-title { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-footer { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }

.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 22px; letter-spacing: 2px; padding: 14px 18px; border-radius: 10px; background: #0a0d11; border: 1px dashed var(--accent); color: #cfe0ff; word-break: break-all; }

.progress { height: 6px; background: #0a0d11; border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7fb2ff); }

.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.player { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; min-height: 240px; }
.player video, .player audio, .player img { width: 100%; max-height: 70vh; display: block; }
.player iframe { width: 100%; height: 70vh; border: none; background: #fff; }
.player audio { padding: 0; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.thumb-large { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 14px; }
.thumb-large img { width: 100%; display: block; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 420px; padding: 12px 18px; border-radius: 10px; background: #1f2937; border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 14px; }
.toast.error { border-color: rgba(248, 81, 73, 0.5); color: #ffb3ae; }
.toast.success { border-color: rgba(63, 185, 80, 0.5); color: #9ae6a6; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

@media (max-width: 860px) {
  .detail { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .topbar nav { order: 3; width: 100%; }
  .userbox { margin-left: auto; }
  .container { padding: 18px 14px 48px; }
  h1 { font-size: 22px; }
}
