/* pwa-youtube — 共享样式（深色主题，移动端自适应） */

:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #eef0f3;
  --text: #1f2937;
  --text-dim: #6b7280;
  --accent: #e50914;
  --accent-hover: #c40a13;
  --border: #e5e7eb;
  --progress-bg: #d8dce2;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== 顶栏 ===== */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

header .back { color: var(--text-dim); font-size: 14px; white-space: nowrap; }
header .back:hover { color: var(--text); }

header .upload-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
header .upload-btn:hover { background: var(--accent-hover); }

/* 版本徽标（发版版本体系锚点，勿删） */
.app-version {
  font-size: 0.7rem;
  font-weight: 400;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
  user-select: none;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ===== 首页网格 ===== */
main { max-width: 1200px; margin: 0 auto; padding: 20px; }

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

.card {
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.card:hover { transform: translateY(-3px); background: var(--bg-hover); }

.card .thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card .duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
}

.card .progress-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  display: none;
}

.card .meta { padding: 10px 12px; }
.card .title {
  font-size: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .added { margin-top: 4px; font-size: 12px; color: var(--text-dim); }

.empty, .error, .loading-hint {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.error { color: #f87171; }

/* ===== 播放页 ===== */
.player-wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.video-container video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* 雪碧图悬停预览（继承 hls 项目实现） */
.thumbnail-preview {
  position: absolute;
  bottom: 70px;
  width: 320px;
  height: 180px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 6px;
  overflow: hidden;
  display: none;
  z-index: 20;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translateX(-50%);
}
.thumbnail-preview.show { display: block; }
.thumbnail-sprite {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: auto;
}

/* 加载 / 错误覆盖层 */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 15px;
  z-index: 15;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.35);
}
.overlay.error { color: #f87171; }

/* ===== 自绘控制条 ===== */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: 0 0 10px 10px;
  border: 1px solid var(--border);
  border-top: none;
  flex-wrap: wrap;
}

.controls button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.controls button:hover { background: var(--bg-hover); }

.progress-wrap {
  position: relative;
  flex: 1;
  min-width: 120px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  overflow: visible;
}
.progress-buffer {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: #c9ced6;
  border-radius: 2px;
}
.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.progress-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  display: none;
}
.progress-wrap:hover .progress-handle { display: block; }

.time { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

.controls select {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
}

/* ===== 移动端 ===== */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  header { padding: 10px 12px; }
  .thumbnail-preview { width: 240px; height: 135px; }
}
