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

:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --border: #2a2a4a;
  --badge-bg: #533483;
  --youtube-red: #ff0000;
  --imdb-yellow: #f5c518;
  --tvdb-green: #6cd491;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.logo span {
  color: var(--text);
  font-weight: 400;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

nav a:hover,
nav a.active {
  color: var(--accent);
}

.controls {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 250px;
  padding: 0.6rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box:focus {
  border-color: var(--accent);
}

.search-box::placeholder {
  color: var(--text-muted);
}

.sort-btn {
  padding: 0.6rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.sort-btn:hover,
.sort-btn.active {
  border-color: var(--accent);
  color: var(--text);
}

.count {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--bg-input);
}

.card-poster-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 3rem;
}

.card-body {
  padding: 0.8rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-video-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-year {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-type {
  font-size: 0.65rem;
}

.badge-type-movie {
  background: #2d6a4f;
  color: #b7e4c7;
}

.badge-type-series {
  background: #1d3557;
  color: #a8dadc;
}

.badge-show {
  background: #4a1942;
  color: #e8a0bf;
}

.badge-series {
  background: var(--badge-bg);
  color: #e0c3fc;
}

.badge-genre {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-rating {
  background: var(--imdb-yellow);
  color: #000;
  font-weight: 700;
}

.card-links {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.card-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s;
}

.card-links a:hover {
  opacity: 0.8;
}

.link-youtube {
  background: var(--youtube-red);
  color: #fff;
}

.link-imdb {
  background: var(--imdb-yellow);
  color: #000;
}

.link-tvdb {
  background: var(--tvdb-green);
  color: #000;
}

.link-tmdb {
  background: #01b4e4;
  color: #fff;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.8rem;
    padding: 1rem;
  }
}
