/* Twitch collapses the channel list into an avatar rail below 1200px. */
@media (max-width: 1199px) {
  .side-nav.side-nav--expanded,
  .side-nav.side-nav--expanded > div {
    width: 5rem !important;
  }

  .side-nav .collapse-toggle,
  .side-nav .side-nav-show-more-toggle__button,
  .side-nav .side-nav-card__link > :not(.side-nav-card__avatar) {
    display: none !important;
  }

  .side-nav .side-nav-card__link {
    width: 4.2rem;
    padding: 0.4rem 0.9rem !important;
  }

  .side-nav .side-nav-header {
    display: flex;
    justify-content: center;
    width: 4.2rem;
    height: 3.6rem;
    margin: 0 !important;
    padding: 0.8rem 1.1rem !important;
  }

  .side-nav .side-nav-header > * {
    display: none;
  }

  .side-nav .side-nav-header::before {
    content: "";
    display: block;
    width: 2rem;
    height: 2rem;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M18 15v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v3l4-2v10l-4-2ZM4 6h12v12H4V6Z'/%3E%3C/svg%3E") center / contain no-repeat;
  }
}

/* Phones: m.youtube.com on top of the desktop DOM. mobile.ts sets [data-ne-mobile] below 600px. */
[data-ne-mobile] ytd-app {
  --ytd-masthead-height: 48px;
}

[data-ne-mobile] body {
  padding-bottom: 57px;
}

[data-ne-mobile] #container.ytd-masthead {
  height: 48px;
  padding: 0 0 0 12px;
}

[data-ne-mobile] #background.ytd-masthead {
  height: 48px;
  background: #0f0f0f;
  backdrop-filter: none;
}

[data-ne-mobile] #guide-button.ytd-masthead,
[data-ne-mobile] #country-code.ytd-topbar-logo-renderer,
[data-ne-mobile] #buttons.ytd-masthead > ytd-button-renderer {
  display: none;
}

[data-ne-mobile] ytd-masthead #logo.ytd-topbar-logo-renderer {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  width: auto;
  min-width: 0;
  overflow: hidden;
}

[data-ne-mobile] ytd-masthead #logo.ytd-masthead {
  width: auto;
  min-width: 0;
}

[data-ne-mobile] ytd-masthead #logo.ytd-topbar-logo-renderer > div {
  flex: none;
  width: 29px;
  height: 20px;
  overflow: hidden;
}

[data-ne-mobile] ytd-masthead #logo-icon.ytd-logo {
  width: 93px !important;
  height: 20px !important;
  padding: 0 !important;
}

.ne-m-topbar-title {
  overflow: hidden;
  color: #fff;
  font: 700 20px/28px Roboto, Arial, sans-serif;
  letter-spacing: -0.2px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

[data-ne-mobile] ytd-masthead #center.ytd-masthead yt-icon-button {
  width: 48px;
  height: 48px;
  padding: 12px;
}

[data-ne-mobile] ytd-masthead ytd-topbar-menu-button-renderer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
}

[data-ne-mobile] tp-yt-app-toolbar.ytd-tabbed-page-header,
[data-ne-mobile] #tabs-container.ytd-tabbed-page-header,
[data-ne-mobile] #tabs-inner-container.ytd-tabbed-page-header {
  width: 100%;
  max-width: none;
  padding: 0;
}

[data-ne-mobile] tp-yt-paper-tabs#tabs.ytd-tabbed-page-header {
  width: 100%;
  margin: 0;
  padding: 0 0 0 14px;
  box-sizing: border-box;
}

[data-ne-mobile] #tabsContainer.tp-yt-paper-tabs {
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x pan-y !important;
}

[data-ne-mobile] tp-yt-paper-tabs#tabs #left,
[data-ne-mobile] tp-yt-paper-tabs#tabs #right {
  display: none;
}

[data-ne-mobile] yt-tab-shape .ytTabShapeTab {
  font-size: 16px;
  line-height: 22px;
}

[data-ne-mobile] ytd-two-column-browse-results-renderer {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

[data-ne-mobile] ytd-item-section-renderer.ytd-section-list-renderer {
  border-bottom: 1px solid rgb(255 255 255 / 0.2);
}

[data-ne-mobile] ytd-item-section-renderer:has(ytd-post-renderer) {
  display: none;
}

[data-ne-mobile] ytd-channel-video-player-renderer {
  display: block;
  padding: 12px 0;
}

[data-ne-mobile] ytd-channel-video-player-renderer #player-container {
  width: 100vw;
  height: calc(100vw * 9 / 16);
  margin: 0;
  border-radius: 0;
  overflow: hidden;
}

[data-ne-mobile] ytd-channel-video-player-renderer #player-container * {
  border-radius: 0 !important;
  width: 100% !important;
  height: 100% !important;
  left: 0 !important;
  top: 0 !important;
}

[data-ne-mobile] ytd-channel-video-player-renderer video {
  object-fit: cover;
  /* The captured frames have the desktop player's rounded corners baked in. */
  transform: scale(1.05);
}

[data-ne-mobile] ytd-channel-video-player-renderer .ytp-chrome-bottom,
[data-ne-mobile] ytd-channel-video-player-renderer .ytp-chrome-top,
[data-ne-mobile] ytd-channel-video-player-renderer .ytp-overlays-container,
[data-ne-mobile] ytd-channel-video-player-renderer #metadata-container ytd-video-meta-block {
  display: none !important;
}

[data-ne-mobile] ytd-channel-video-player-renderer #content {
  margin: 0;
  padding: 12px 12px 0;
}

[data-ne-mobile] ytd-channel-video-player-renderer #metadata-container {
  margin: 0;
  padding: 0;
}

[data-ne-mobile] ytd-channel-video-player-renderer #title {
  display: -webkit-box;
  max-height: none;
  margin: 0;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font: 400 14px/17.5px Roboto, Arial, sans-serif;
}

[data-ne-mobile] ytd-shelf-renderer {
  padding: 12px 0 0;
}

[data-ne-mobile] ytd-shelf-renderer .grid-subheader {
  margin: 0;
  padding: 0 12px;
}

[data-ne-mobile] ytd-shelf-renderer #title-container,
[data-ne-mobile] ytd-shelf-renderer #contents.ytd-shelf-renderer {
  margin: 0;
  padding: 0;
}

[data-ne-mobile] ytd-shelf-renderer #play-button,
[data-ne-mobile] ytd-shelf-renderer #left-arrow,
[data-ne-mobile] ytd-shelf-renderer #right-arrow {
  display: none;
}

[data-ne-mobile] ytd-shelf-renderer #title.ytd-shelf-renderer,
[data-ne-mobile] ytd-reel-shelf-renderer #title {
  font: 700 18px/24px Roboto, Arial, sans-serif;
}

[data-ne-mobile] ytd-shelf-renderer #scroll-container.yt-horizontal-list-renderer {
  overflow: visible;
  margin: 0;
}

[data-ne-mobile] ytd-shelf-renderer #items.yt-horizontal-list-renderer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 12px 0;
  box-sizing: border-box;
  transform: none !important;
  white-space: normal;
}

[data-ne-mobile] ytd-shelf-renderer:not([data-ne-expanded]) #items.yt-horizontal-list-renderer > :nth-child(n + 4) {
  display: none;
}

[data-ne-mobile] ytd-shelf-renderer #items.yt-horizontal-list-renderer > * {
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupViewModelHost {
  flex-direction: row;
  width: 100% !important;
  max-width: none !important;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupViewModelContentImage {
  flex: none;
  width: 160px;
  padding: 0 8px 0 0 !important;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupViewModelMetadata {
  flex: 1;
  min-width: 0;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupMetadataViewModelAvatar {
  display: none;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupMetadataViewModelTitle {
  margin-right: 36px !important;
  padding-right: 0 !important;
  font-size: 14px !important;
  line-height: 17.5px !important;
  font-weight: 400 !important;
  max-height: none !important;
  -webkit-line-clamp: 3 !important;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupMetadataViewModelMetadata {
  font-size: 12px;
  line-height: 15px;
}

[data-ne-mobile] ytd-rich-grid-renderer #contents.ytd-rich-grid-renderer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  width: 100% !important;
  max-width: none;
  margin: 0 !important;
  padding: 12px 12px 0;
}

[data-ne-mobile] ytd-rich-grid-renderer ytd-rich-item-renderer,
[data-ne-mobile] ytd-rich-grid-renderer ytd-rich-item-renderer yt-lockup-view-model {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
}

[data-ne-mobile] ytd-grid-channel-renderer #channel {
  width: 100%;
}

[data-ne-mobile] ytd-grid-channel-renderer #channel-info {
  display: grid;
  grid-template-columns: 160px 1fr;
  grid-template-rows: 1fr auto 1fr;
  column-gap: 8px;
  width: 100%;
  height: 90px;
  text-align: left;
}

[data-ne-mobile] ytd-grid-channel-renderer yt-img-shadow {
  grid-row: 1 / 4;
  justify-self: center;
  width: 90px;
  height: 90px;
  margin: 0;
}

[data-ne-mobile] ytd-grid-channel-renderer yt-img-shadow img {
  width: 90px;
  height: 90px;
}

[data-ne-mobile] ytd-grid-channel-renderer #title {
  align-self: end;
  margin: 0;
  font: 400 14px/17.5px Roboto, Arial, sans-serif;
}

[data-ne-mobile] ytd-grid-channel-renderer #thumbnail-attribution {
  align-self: start;
  margin: 0;
  font-size: 12px;
  line-height: 15px;
}

[data-ne-mobile] ytd-grid-channel-renderer #subscribe {
  display: none;
}

.ne-m-expand {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 12px 0;
  border: 0;
  color: #f1f1f1;
  background: none;
}

[data-ne-expanded] .ne-m-expand svg {
  transform: rotate(180deg);
}

[data-ne-mobile] ytd-reel-shelf-renderer #items.yt-horizontal-list-renderer > * {
  width: 148px !important;
  padding-right: 8px !important;
}

[data-ne-mobile] ytd-reel-shelf-renderer #items.yt-horizontal-list-renderer {
  padding: 0 12px;
}

.ne-m-pivot {
  position: fixed;
  inset: auto 0 0;
  z-index: 2030;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 57px;
  border-top: 1px solid rgb(255 255 255 / 0.1);
  /* Nearly opaque: where the blur is not drawn, the feed must not read through the labels. */
  background: rgb(15 15 15 / 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.ne-m-pivot-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #f1f1f1;
  font: 400 11px Roboto, Arial, sans-serif;
  text-decoration: none;
}

.ne-m-pivot-tab yt-icon {
  display: block;
  flex: none;
  margin: 0 !important;
  width: 24px;
  height: 24px;
}

[data-ne-mobile] #page-header-container.ytd-tabbed-page-header {
  padding: 16px 16px 16px;
  box-sizing: border-box;
}

[data-ne-mobile] #page-header-banner.ytd-tabbed-page-header,
[data-ne-mobile] #page-header.ytd-tabbed-page-header {
  margin: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

[data-ne-mobile] .ytFlexibleActionsViewModelActionRowAction {
  padding: 0 !important;
}

[data-ne-mobile] .ytFlexibleActionsViewModelActionRowAction:not(:first-child) {
  display: none;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelLeadingIcon {
  display: none;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelLeadingIcon + [aria-label*="просмотр"]::after {
  content: " просмотров";
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelMetadataRow:not(:has(.ytContentMetadataViewModelLeadingIcon)) ~ .ytContentMetadataViewModelMetadataRow .ytContentMetadataViewModelMetadataTextLastPart[aria-label$="назад"] {
  display: none;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelMetadataTextLastPart[aria-label$="назад"] {
  font-size: 0 !important;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelMetadataTextLastPart[aria-label$="назад"]::after {
  content: "· " attr(aria-label);
  font-size: 12px;
}

[data-ne-mobile] :is(ytd-shelf-renderer, ytd-rich-grid-renderer) .ytLockupViewModelHost {
  min-height: 90px;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelMetadataRow {
  flex-wrap: wrap;
  margin: 0 !important;
  line-height: 15px;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelIcon {
  display: none;
}

[data-ne-mobile] .ytLockupViewModelHost yt-content-metadata-view-model {
  font-size: 12px !important;
  line-height: 15px !important;
}

[data-ne-mobile] ytd-reel-shelf-renderer #header.ytd-reel-shelf-renderer {
  margin: 12px 0;
  padding: 0 4px 0 12px;
}

[data-ne-mobile] ytd-reel-shelf-renderer #scroll-outer-container,
[data-ne-mobile] ytd-reel-shelf-renderer #scroll-container {
  width: 100% !important;
  max-width: none !important;
}

[data-ne-mobile] ytd-reel-shelf-renderer #left-arrow,
[data-ne-mobile] ytd-reel-shelf-renderer #right-arrow {
  display: none !important;
}

[data-ne-mobile] ytd-reel-shelf-renderer ytm-shorts-lockup-view-model {
  position: relative;
  display: block;
  width: 148px !important;
  height: 252px;
  overflow: hidden;
  border-radius: 8px;
}

[data-ne-mobile] ytd-reel-shelf-renderer ytm-shorts-lockup-view-model > a,
[data-ne-mobile] ytd-reel-shelf-renderer ytm-shorts-lockup-view-model > a :is(div, yt-thumbnail-view-model) {
  width: 148px !important;
  height: 252px !important;
  padding: 0 !important;
  margin: 0 !important;
}

[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostOutsideMetadata {
  position: absolute;
  inset: auto 0 0;
  width: auto;
  padding: 40px 8px 8px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.75));
}

[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostOutsideMetadata :is(a, span, h3, div) {
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostOutsideMetadata .shortsLockupViewModelHostOutsideMetadataSubhead span {
  font-size: 12px;
  line-height: 16px;
}

[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostMetadataTitle,
[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostMetadataTitle span {
  max-height: 60px;
  -webkit-line-clamp: 3;
}

[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostOutsideMetadata {
  top: 0;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  background: linear-gradient(transparent 55%, rgb(0 0 0 / 0.75));
}

[data-ne-mobile] ytd-reel-shelf-renderer .shortsLockupViewModelHostOutsideMetadataMenu {
  position: absolute;
  inset: 0 0 auto auto;
  pointer-events: auto;
}

[data-ne-mobile] ytd-channel-video-player-renderer #title a {
  display: inline;
  white-space: normal;
}

[data-ne-mobile] ytd-shelf-renderer #title-container {
  height: 24px;
}

[data-ne-mobile] ytd-shelf-renderer #title-container #menu {
  display: none;
}

[data-ne-mobile] ytd-shelf-renderer #subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
}

[data-ne-mobile] .ytPageHeaderViewModelTitle .ytIconWrapperHost {
  width: 18px !important;
  height: 18px !important;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelMetadataTextLastPart[aria-label$="назад"] {
  flex-basis: 100%;
  margin: 0 !important;
}

[data-ne-mobile] .ytLockupMetadataViewModelMenuButton {
  transform: translate(-12px, 10px);
}

.ne-m-handle {
  color: #aaa;
  font: 400 12px/15px Roboto, Arial, sans-serif;
}

.ne-m-owner ~ * {
  display: none !important;
}

[data-ne-mobile] .ytLockupViewModelHost .ytContentMetadataViewModelMetadataText {
  font-size: 12px;
  line-height: 15px;
}

[data-ne-mobile] .ytLockupViewModelHost:has(yt-collections-stack) {
  padding-top: 8px;
}

[data-ne-mobile] yt-tab-shape ytd-expandable-tab-renderer {
  display: none;
}

[data-ne-mobile] yt-tab-shape:has(ytd-expandable-tab-renderer)::after {
  content: "Поиск";
  color: #aaa;
  font: 500 16px/48px Roboto, Arial, sans-serif;
}

[data-ne-mobile] :is(.ne-snackbar, .ne-exile-player) {
  bottom: 69px;
}

[data-ne-mobile] .ne-car-bar {
  bottom: calc(69px + env(safe-area-inset-bottom));
}

:root[data-ne-mobile]:has(.ne-exile-player[data-open]) .ne-snackbar {
  bottom: 145px;
}

/* The truck shakes the page, which must not turn into a sideways scroll. */
[data-ne-mobile] {
  overflow-x: clip;
}

/* With the root clipped, the body's own scroll no longer passes to the viewport: Safari then makes the body the scroller and the pinned header has nothing to stick to. */
:root[data-ne-mobile] > body {
  overflow: visible;
}

/* The thumbnail link is wider than the picture here, so the badge has to be held to the picture. */
[data-ne-mobile] .ne-beast-badge {
  max-width: 132px;
}

[data-ne-mobile] .ytLockupViewModelHost:has(yt-content-metadata-view-model badge-shape) .ytLockupMetadataViewModelTitle {
  -webkit-line-clamp: 2 !important;
}

/* The truck's search bar takes the bottom spot, so the player moves above it. */
[data-ne-mobile]:has(.ne-car-bar) .ne-exile-player {
  bottom: calc(125px + env(safe-area-inset-bottom));
}
