:root {
  --accent: #40af64;
  --accent-dark: #339452;
  --bg: #f0f0f0;
  --surface: #ffffff;
  --text: #333333;
  --muted: #8a8a8a;
  --border: #d9d9d9;
  --header: #222222;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* Header */

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.3);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 16px;
}

.logo {
  flex-shrink: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.logo span {
  color: var(--accent);
}

.search {
  display: flex;
  flex: 1;
  max-width: 640px;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 2px solid var(--accent);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.search button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 40px;
  border: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.search button:hover {
  background: var(--accent-dark);
}

/* Page */

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

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 20px 0 14px;
}

.title-row h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.clear-search {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.clear-search:hover {
  color: var(--text);
}

/* Cards */

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

.card {
  min-width: 0;
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: #ccc;
}

.thumb-link {
  position: absolute;
  inset: 0;
}

.thumb img,
.thumb video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb video {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

/* Pill in the top-right corner: icon + "Tap for preview". The whole pill is the button. */
.preview-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px 0 4px;
  border: 0;
  border-radius: 16px;
  background: rgb(0 0 0 / 0.65);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
  transition: background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.preview-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
}

.preview-btn:hover,
.preview-btn[aria-pressed="true"] {
  background: rgb(0 0 0 / 0.85);
}

.preview-btn:active {
  transform: scale(0.95);
}

.preview-btn svg {
  width: 15px;
  height: 15px;
}

.preview-btn .icon-stop,
.preview-btn .label-stop,
.preview-btn[aria-pressed="true"] .icon-play,
.preview-btn[aria-pressed="true"] .label-play {
  display: none;
}

.preview-btn[aria-pressed="true"] .icon-stop,
.preview-btn[aria-pressed="true"] .label-stop {
  display: block;
}

.thumb video.playing {
  opacity: 1;
}

.duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 1;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgb(0 0 0 / 0.75);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.info {
  padding: 7px 2px 0;
}

.title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 3px;
  font-size: 13px;
}

.tags a {
  color: var(--accent);
}

.tags a:hover {
  text-decoration: underline;
}

.tags .channel::before {
  content: "▶ ";
  font-size: 10px;
}

.tags .model::before {
  content: "★ ";
}

.meta {
  display: flex;
  gap: 14px;
  margin: 3px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.meta-views::before {
  content: "👁 ";
}

/* Loading skeletons */

.skeleton .thumb {
  animation: pulse 1.2s ease-in-out infinite;
}

.skeleton .line {
  height: 12px;
  margin-top: 8px;
  border-radius: 3px;
  background: #ddd;
}

.skeleton .line.short {
  width: 50%;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

/* Status + pagination */

.status {
  padding: 40px 0;
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 30px;
}

.pagination button {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: default;
}

.pagination button:disabled:not(.active) {
  opacity: 0.4;
  cursor: default;
}

.pagination .dots {
  align-self: center;
  color: var(--muted);
}

@media (max-width: 600px) {
  .header-inner {
    gap: 12px;
  }

  .logo {
    font-size: 21px;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
