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

:root {
  --bg: #0e1015;
  --surface: #161a22;
  --surface-2: #1d222d;
  --border: #262d3a;
  --text: #e9ecf2;
  --muted: #9aa4b5;
  --accent: #ff4d5a;
  --accent-2: #7c5cff;
  --green: #34d399;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 16, 21, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-sub {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.back-link {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--text);
}

.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.active {
  color: #fff;
  background: var(--accent);
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}

.search-form input {
  width: 220px;
  padding: 7px 12px;
}

.search-form button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  white-space: nowrap;
  transition: all 0.2s;
}

.search-form button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 16px;
  transition: all 0.2s;
}

.admin-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ---------- 首页 ---------- */
.featured-section {
  margin: 20px 0 8px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 22px 0 14px;
}

.featured-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.featured-row .video-card {
  flex: 0 0 240px;
}

.list-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.list-count {
  color: var(--muted);
  font-size: 13px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.video-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #232a38, #12151c) center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb .play-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.thumb .play-icon::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 16px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  margin-left: 4px;
}

.video-card:hover .play-icon {
  opacity: 1;
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}

.card-body {
  padding: 10px 12px 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 39px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.card-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading,
.error-tip {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
}

.error-tip {
  color: var(--accent);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 28px 0 40px;
}

.page-link {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  transition: all 0.2s;
}

.page-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

.page-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-link.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- 播放页 ---------- */
.watch-layout {
  max-width: 980px;
}

.player-wrap {
  position: relative;
  margin-top: 20px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.player-wrap video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  background: rgba(10, 12, 16, 0.92);
  color: #fca5a5;
  font-size: 15px;
  line-height: 1.7;
}

.watch-title {
  font-size: 24px;
  font-weight: 700;
  margin: 18px 0 10px;
}

.watch-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.watch-desc {
  margin: 14px 0 10px;
  color: #c4cbd7;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 16px;
  font-size: 14px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e63946);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: transparent;
  border-color: rgba(255, 77, 90, 0.4);
  color: #ff6b76;
}

.btn-danger:hover {
  background: rgba(255, 77, 90, 0.12);
  border-color: var(--accent);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* ---------- 管理后台 ---------- */
.login-panel {
  display: flex;
  justify-content: center;
  padding: 80px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
}

.login-card p {
  margin-bottom: 18px;
}

.login-card input {
  margin-bottom: 16px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 24px 0 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab-btn.active {
  color: var(--accent);
  background: rgba(255, 77, 90, 0.1);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input[type="search"] {
  width: 240px;
}

.toolbar-count {
  color: var(--muted);
  font-size: 13px;
}

.spacer {
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  background: var(--surface-2);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.video-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.video-cell img,
.video-cell .no-cover {
  width: 96px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, #232a38, #12151c);
}

.video-cell .no-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 20px;
}

.video-cell .cell-title {
  font-weight: 600;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-title:hover {
  color: var(--accent);
}

.cell-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.badge-type {
  display: inline-block;
  background: rgba(124, 92, 255, 0.15);
  color: #b9a8ff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  text-transform: uppercase;
}

.badge-yes {
  color: var(--green);
}

.badge-no {
  color: var(--muted);
}

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

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  font-size: 20px;
  margin-bottom: 18px;
}

.modal-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.modal-card label small {
  display: block;
  margin: 4px 0 6px;
  color: #6f7888;
}

.modal-card input,
.modal-card select,
.modal-card textarea {
  margin-top: 6px;
}

.form-row {
  display: flex;
  gap: 14px;
}

.form-row label {
  flex: 1;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--text) !important;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- 批量添加 ---------- */
.batch-preview {
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
}

.batch-preview .bp-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
}

.batch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}

.batch-item:last-child {
  border-bottom: none;
}

.batch-item .bi-index {
  color: var(--muted);
  min-width: 26px;
  flex-shrink: 0;
}

.batch-item .bi-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-item .bi-url {
  color: var(--muted);
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-item .bi-status {
  flex-shrink: 0;
  font-weight: 600;
}

.batch-item.ok .bi-status {
  color: var(--green);
}

.batch-item.err .bi-status,
.batch-item.err .bi-msg {
  color: var(--accent);
}

.batch-item .bi-msg {
  flex-shrink: 0;
  max-width: 30%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 200;
  font-size: 14px;
}

.toast.success {
  border-color: var(--green);
}

.toast.error {
  border-color: var(--accent);
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .header-inner {
    flex-wrap: wrap;
    padding: 10px 16px;
    row-gap: 8px;
  }

  .main-nav {
    order: 3;
    flex-basis: 100%;
  }

  .search-form {
    margin-left: auto;
    min-width: 0;
  }

  .search-form input {
    width: 150px;
  }

  .watch-title {
    font-size: 19px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
}
