:root {
  color-scheme: dark;
  --bg: #000;
  --chip: #2a2a2a;
  --chip-on: #3d3d3d;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --accent: #f22e52;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.library {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 10px 12px;
}

.library__sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 88%, transparent);
  padding-top: calc(8px + var(--safe-t));
  padding-bottom: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
}

.library__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.library__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
}

.library__crumb {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  text-align: right;
}

.filter-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-left: -10px;
  margin-right: -10px;
  padding-left: 10px;
  padding-right: 10px;
}

.filter-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.filter-chip.is-on {
  background: #3a3a3a;
  color: #fff;
  font-weight: 600;
}

.film-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 8px;
  min-height: 120px;
}

.film-card {
  display: block;
  color: inherit;
  text-decoration: none;
  contain: layout style paint;
}

.film-card--skeleton .film-card__cover {
  background: linear-gradient(110deg, #1a1a1a 8%, #2a2a2a 18%, #1a1a1a 33%);
  background-size: 200% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

.film-card--skeleton .film-card__name {
  height: 28px;
  margin-top: 6px;
  border-radius: 4px;
  background: #1a1a1a;
  animation: shimmer 1.1s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.film-card__cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1a1a;
}

.film-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1a1a1a;
}

.film-card__score {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 28px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.film-card__plays {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

.film-card__play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 7px;
  border-color: transparent transparent transparent #fff;
  flex-shrink: 0;
}

.film-card__name {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library__empty {
  padding: 40px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.scroll-sentinel {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-sentinel__dots {
  display: flex;
  gap: 6px;
  padding: 12px 0;
}

.scroll-sentinel__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 0.9s ease-in-out infinite;
}

.scroll-sentinel__dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.scroll-sentinel__dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}
