:root {
  --bg: #000000;
  --bg-soft: #1b1b1b;
  --card: #1a1a1a;
  --card-hover: #232323;
  --line: #2a2a2a;
  --text: #e7e7e7;
  --muted: #9aa0a6;
  --accent: #e50914;
  --accent-2: #ffc107;
  --radius: 4px;
}

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

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img {
  display: block;
  width: 100%;
}

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

/* ---------- Header top bar ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #000;
}

.header__bar {
  border-bottom: 1px solid var(--line);
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

.logo__mark {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
}

.logo__word {
  color: #fff;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.topnav a {
  padding: 7px 12px;
  border-radius: 4px;
  color: #c9ccd1;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.topnav a:hover {
  color: #fff;
  background: var(--bg-soft);
}

.topnav a.is-active {
  color: #fff;
  background: var(--bg-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.search {
  position: relative;
  flex: 1;
  max-width: 620px;
  margin: 0 auto;
  display: flex;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 48px 0 14px;
  background: #fff;
  color: #111;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  outline: none;
  font-size: 14px;
}

.search input::placeholder {
  color: #8a8a8a;
}

.search__btn {
  position: absolute;
  right: 0;
  top: 0;
  width: 42px;
  height: 38px;
  border: none;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
}

.search__btn:hover {
  background: #c30812;
}

/* ---------- Secondary nav ---------- */
.subnav {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.subnav__inner {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: none;
}

.subnav__inner::-webkit-scrollbar {
  display: none;
}

.subnav__link {
  flex-shrink: 0;
  padding: 9px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #c9ccd1;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.subnav__link:hover {
  color: #fff;
}

.subnav__link.is-active {
  color: #fff;
  border-bottom-color: var(--accent);
}

/* ---------- Filter bar ---------- */
.filterbar {
  margin: 14px 0 16px;
}

.filterbar__tabs {
  display: flex;
  gap: 18px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 13px;
}

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

.ftab b {
  color: var(--text);
}

.ftab.is-active,
.ftab.is-active b {
  color: var(--accent);
}

.results-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 12px;
}

.results-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Video grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px 10px;
}

.grid-loader {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: tipSpin 0.8s linear infinite;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
}

.card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 3px;
  overflow: hidden;
  background: var(--card);
}

.card__badge {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 3;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(40, 40, 40, 0.85);
  color: #dcdcdc;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
}

.card__thumb img {
  height: 100%;
  object-fit: cover;
  opacity: var(--cover-opacity, 1);
  transition: transform 0.35s ease, opacity 1s linear;
}

body.is-loading {
  --cover-opacity: 0;
}

.card__censor {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70%;
  height: 74%;
  transform: translate(-50%, -50%);
  z-index: 2;
  border-radius: 6px;
  background: rgba(15, 17, 21, 0.16);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  pointer-events: none;
}

.card:hover .card__thumb img {
  transform: scale(1.05);
}

.card__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.55));
  opacity: 0;
  z-index: 4;
  transition: opacity 0.2s;
}

.card:hover .card__play {
  opacity: 1;
}

.card__play svg {
  width: 46px;
  height: 46px;
  color: var(--accent-2);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.card__duration {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.78);
  font-size: 11px;
  font-weight: 700;
  z-index: 3;
}

.card__fav {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 5;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, color 0.15s, background 0.15s, transform 0.15s;
}

.card:hover .card__fav {
  opacity: 1;
}

.card__fav:hover {
  transform: scale(1.12);
  background: rgba(0, 0, 0, 0.75);
}

.card__fav svg {
  width: 15px;
  height: 15px;
}

.card__fav.is-on {
  opacity: 1;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.6);
}

.card__body {
  padding: 6px 0 0;
}

.card__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: #e0e0e0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.card:hover .card__title {
  color: #fff;
  text-decoration: underline;
}

.card__meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.card__sub {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card__rate {
  margin-left: auto;
  color: #3ddc84;
  font-weight: 700;
}

/* ---------- Pagination ---------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 24px 0 48px;
}

.pager--top {
  justify-content: flex-start;
  margin: 4px 0 16px;
}

.pager button {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: #c9ccd1;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.pager button:hover:not(:disabled) {
  color: #fff;
  background: var(--bg-soft);
}

.pager button.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 12.5px;
}

.footer__inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.footer__links a:hover {
  color: #fff;
}

/* ---------- Loading tip ---------- */
.loading-tip {
  position: fixed;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(600px, calc(100% - 32px));
  padding: 16px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1b1f28, #14171e);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  animation: tipIn 0.4s ease;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.loading-tip.is-hidden {
  opacity: 0;
  transform: translate(-50%, -14px);
  pointer-events: none;
}

.loading-tip.is-warn {
  border-color: var(--accent);
  background: linear-gradient(135deg, #2a1113, #1c0d0e);
  box-shadow: 0 18px 60px rgba(229, 9, 20, 0.5);
  animation: tipWarn 0.5s ease;
}

.loading-tip.is-warn .loading-tip__title {
  background: linear-gradient(90deg, #ff6b6b, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.loading-tip.is-warn .loading-tip__text {
  color: #ffb3b3;
  font-weight: 600;
}

.loading-tip.is-warn .loading-tip__count b {
  color: #ff6b6b;
}

@keyframes tipWarn {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  20% {
    transform: translate(calc(-50% - 7px), 0);
  }
  40% {
    transform: translate(calc(-50% + 7px), 0);
  }
  60% {
    transform: translate(calc(-50% - 5px), 0);
  }
  80% {
    transform: translate(calc(-50% + 5px), 0);
  }
}

.loading-tip__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.loading-tip__title {
  font-weight: 700;
  font-size: 15px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.loading-tip__count {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
}

.loading-tip__count b {
  color: var(--accent-2);
  font-size: 15px;
}

.loading-tip__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: tipSpin 0.8s linear infinite;
}

.loading-tip__text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

@keyframes tipSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes tipIn {
  from {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .topnav {
    display: none;
  }
}

@media (max-width: 760px) {
  .container {
    padding: 0 8px;
  }
  .header__inner {
    height: 56px;
    gap: 10px;
  }
  .search input {
    font-size: 16px;
  }
  .grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .card__thumb {
    border-radius: 0;
  }
  .card__title {
    font-size: 15px;
  }
  .card__meta {
    font-size: 13px;
  }
  .pager--top {
    display: none;
  }
  .loading-tip {
    top: 96px;
  }
}
